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
SFRichSFRich 

SOQL join query

I am trying to get the profile name for the user that last modified an Opportunity to distinguish administrator updates versus user updates.  This code doesn't seem to be working:

 

Select o.id, o.lastmodifiedby.name, o.lastmodifiedby.profile.name From Opportunity o

 

If this is too many levels, can I reference the current user id in a trigger?  Will all the records in the 'new' collection of the trigger be for just for that current user or could it be for multiple users?

SuperfellSuperfell
You can query that many hops (the limit is 5), what's not working ?
SFRichSFRich

Thanks for the encouragement.  I got it to work by removing the 'o.' references and capitalized the relationship names.

 

Select id, LastModifiedBy.Name, LastModifiedBy.Profile.Name From Opportunity

 

Thanks