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
Research DeveloperResearch Developer 

user object trigger

We need to update a checkbox field to true on the Service Resource object if the logeed in user is the manager or manager.manager of the service Resource user record. Please suggest.
Andrew GAndrew G
Triggers and flows will only function on a DML event (e.g. a save event).   Therefore having a checkbox respond based on the logged in user without a DML event is not possible.

Perhaps expand on what the business need is and we could suggest a solution.

regards
Andrew
Research DeveloperResearch Developer
There is a isManager custon field on the service resource standard object that will be true in case the logged in user is the manager or manager.manager of the user i.e. RelatedRecordId field on the service resource object.

so when the manager will login, he/she can see all the reportees under him/her on the basis of IsManager field.
Andrew GAndrew G
If we were talking standard Owner fields , you could try something along the lines of below:
OR( 
  $User.Alias =  Owner:User.Manager.Alias,
  $User.Alias =  Owner:User.Manager.Manager.Alias 
)
I am assuming you are using Field Service, hence the Service Resource object.  From memory, (it has been a while since I worked with FSL), to be a service resource you need to have a user record so that a license can be assigned for the resource to appear on the Gantt.

So without  having the schema in front of me, something like:
OR( 
  $User.Alias =  RelatedRecord.User.Manager.Alias,
  $User.Alias =  RelatedRecord.User.Manager.Manager.Alias 
)
regards
Andrew