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
ATTUS TechATTUS Tech 

lastmodifiedbyid - need user name

This seems like a silly question, but I have not been able to find the answer.  How do I get the username from the lastmodifiedbyid on custom objects?  I've queried the user object, but it does not understand the relationship with 'user'.

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

select lastModifiedBy.Name from foo__c ...

All Answers

SuperfellSuperfell

select lastModifiedBy.Name from foo__c ...

This was selected as the best answer
ATTUS TechATTUS Tech

That got it, thanks.  Information like this should be easier to find.

ATTUS TechATTUS Tech

I saw the reference, but could not find anything about the specifics of lastmodifiedby.

 

SuperfellSuperfell

There's nothing special about lastModifiedBy its the same as all the other Foreign Key fields.

ATTUS TechATTUS Tech

I still do not see anything in the doc that would have led me to this solution.

Ryan ThomasRyan Thomas

What's confusing to many users is that in a query tool like Workbench, you see LastModifiedById, but you can't get to the user's name from there.

You have to trim the "Id" part and use LastModifiedBy in order to make it work.  LastModifiedBy.Name