function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MicheleMcgeoyMicheleMcgeoy 

SOQL where clause using $user.id

I'm trying to do a select for data for the currently logged in user with the global variable {!$User.id} in a trigger.
This statement runs fine:
[SELECT j.id, j.Subject, j.CallDurationInSeconds, j.CreatedDate, j.status, j.Description, j.CreatedByID  
FROM Task  j  WHERE (j.CreatedDate = today AND CreatedByID = '00540000001Gii5AAC' AND j.Status = 'Completed')
But when I replace the hard coded ID with {!User.id} I get an error.
Thanks, Michele
Best Answer chosen by Admin (Salesforce Developers) 
testrest97testrest97
SELECT j.id, j.Subject, j.CallDurationInSeconds, j.CreatedDate, j.status, j.Description, j.CreatedByID  
FROM Task  j  WHERE (j.CreatedDate = today AND CreatedByID =:UserInfo.getUserId() AND j.Status = 'Completed')