You need to sign in to do that
Don't have an account?
Dave Berenato
GetUserID in String Select Query
I need to reference a put a Select Query into a String, but it won't process system data like getUserId() (or system.now, although I'm not sure because the error message centers on getUserId()).
Here's what I have:
Here's what I have:
String UserID = UserInfo.getUserId(); String myRequest = 'SELECT id, Owner.Id, type, subject,'+ ' FROM Event' + ' WHERE Owner.Id = '+UserId+' AND RecordTypeId = \'0126A0000004Qle\' And (ActivityDateTime = LAST_N_DAYS:30 OR (ActivityDate = TODAY And ActivityDateTime < ' + system.now() + ' ))';Error message is "System.QueryExecption: unexpected token:" and then my UserId.
All Answers
I think its cause the your UserId needs to be passed in single quotes, notice the way you have passed the Recordtype You ll also have to do the same for userid
Hope it helps
RD
And got an Error Message of:
System.QueryException: line 1:692 no viable alternative at character ' '
I tried putting a space between the single quotes. Does Salesforce distinguish between an open quote and an end quote?
I tried:
And got:
System.QueryException: value of filter criterion for field 'ActivityDateTime' must be of type dateTime and should not be enclosed in quotes
But if I take away the quotes and leave just
I go back to the error message about the no viable alternative to character ''
What do you think?
String UserID = UserInfo.getUserId(); String myRequest = 'SELECT id, Owner.Id, type, subject,' +
' FROM Event' + ' WHERE Owner.Id = '+UserId+' AND RecordTypeId = \'0126A0000004Qle\' And (ActivityDateTime = LAST_N_DAYS:30 OR (ActivityDate = TODAY And ActivityDateTime < ' + system.now() + ' ))';