You need to sign in to do that
Don't have an account?
Ezmo
Query Owner Id using Current User Id
Hi there, I'm quite new to coding and to apex so please bare with me. :smileywink:
I am trying to create an soql query which I essentially want to work like this:
SELECT Id FROM Log_Book__c WHERE Owner Id = Current User Id
Does anyone know how I can achieve this?
Thank you for your time.
Try this
SELECT Id FROM Log_Book__c WHERE OwnerId =:UserInfo.getUserId();
Patcs
All Answers
Try this
SELECT Id FROM Log_Book__c WHERE OwnerId =:UserInfo.getUserId();
Patcs
That worked :smileyhappy:
just had to change OwnerId to Owner.Id
Thank you very much!!
Now I just need to figure out how to implement it where I want it.
What I'm trying to do is as follows
public void addObjective(){
objective.add(new Objective__c(Log_Book__c = logbook));
}
but I get the following
Error: Compile Error: Invalid initial expression type for field Objective__c.Log_Book__c, expecting: Id at line 19 column 54
Use logbook.Id instead of logbook.