1

I have a request to build an approval process on a custom object and the request should be routed to the "Director" (ie, the record owner's manager's manager), and it appears the way to accomplish this is with a trigger.

From what I've read, this is what I think I need:

I need to create a 'Director' field on the User object that will populate the manager of the user's manager to reference for the approval.

On the User object, the trigger should fire whenever the Manager != NULL or if the user's manager is changed and update the Director field.

How can I implement this requirement?

3

I think you'll be able to implement this requirement without any Apex. Instead you should be able to use Process Builder to retrieve and set this field.

  1. Create a new Process Builder flow.
  2. The process starts when: a record changes.
  3. Add Object: User.
    • Start the process: when a record is created or edited.
  4. Add Criteria named something like "Manager Changed". Use a formula:

    OR(
        ISNEW(), ISCHANGED([User].ManagerId)
    )
    
  5. Add an action to update the record which triggered the flow.
  6. Select your lookup field, then set the Type: Field Reference.
    • First select the Manager ID > option (includes arrow).
    • Next select the Manager ID option (without arrow).
  7. Save your action and your flow.
  8. Activate.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.