String Value of ID returns more than ID

You're calling String.valueOf() on the Event Sobject itself, not the Id string. As written, your first line should be:

EventIdString = String.valueOf( [select id from Event where Id=: (ApexPages.currentPage().getParameters().get('EventId'))].Id);

But you don't even need to use String.valueOf(). ID can be directly cast to String:

EventIdString = (String)[select id from Event where Id=: (ApexPages.currentPage().getParameters().get('EventId'))].Id;

And even that is superfluous! If your variable is already a string, you can simply:

EventIdString = [select id from Event where Id=: (ApexPages.currentPage().getParameters().get('EventId'))].Id;

Because IDs are strings. Or...you know:

EventIdString = ApexPages.currentPage().getParameters().get('EventId');

Works just fine too.


Technically, since you're passing the value as a String already, you probably don't need to query the value at all:

TM.Meeting__c = ApexPages.currentPage().getParameters().get('EventId');

However, say you wanted to validate the value first, to make sure the user can see it (so they're not just faking a value), you could do this:

String eventId = ApexPages.currentPage().getParameters().get('EventId');
if([SELECT COUNT() FROM Event WHERE Id = :eventId] == 1) {
    TM.Meeting__c = Id.valueOf(eventId);
}

It seems to me that you should just be doing the following:

TM.Meeting__c = ApexPages.currentPage().getParameters().get('EventId');

As Christian mentioned, your current code is trying to perform String.valueOf on the result of a SOQL query, which would be an SObject. Unlike SQL, if you query a single column/field and expect to get one result, you cannot assume you will just get a simple String back. You have to save the result to the appropriate SObject type and then you can parse out the fields you specified in your SOQL query.