I have Email Notification functionality but finding some difficulties in it.

My Requirement : I have custom field(look up datatype) called Assign_To__c which is look up to User object(standard salesforce user object). Whenever record is submitted with assign_to__c field is not equal to null, it should send an email notification to that user as well as his higher officer.

for example : see the role hierarchy below

enter image description here

Whenever Developer 1 is assigned then it should send email alert to developer1 and his Team Lead. This is the way I want to do. I think Workflow will work here. But I don't know the exact way to accomplish this(Don't know Which fields to use).

  • What has your role hierarchy has to do with it? Or are you just using that screenshot to illustrate your custom lookup behavior visually? The 2 are not related. Feb 11, 2016 at 10:52
  • Assign_to__c is a look up field to Users. So I assigned users to those developer 1, 2, 3 and 4. Every Developer Role has one User. I Shown screenshot for better understanding of my requirement. Feb 11, 2016 at 10:56
  • Are you looking for code or declarative? Feb 12, 2016 at 23:58

2 Answers 2


The problem is that there could be more than one user assigned the role "Team Lead". But what you probably want is the specific Team Lead for a specific Developer. (Your role hierarchy seems a little wrong, since you probably only need one role to represent developers)

Every User has a .Manager, so I'd use that to fire an email.

You will have to ensure that every User has a manager assigned.

  • Thanks for your valuable answer. Suppose If I am arranged all the developers in one role(all the developers in one role as you said). What will be the workaround for my email notification?(workflow criteria's) Feb 11, 2016 at 11:09
  • My solution doesn't use role hierarchy, it uses User.Manager. If you really wanted to use role hierachy then you can query the object "UserRole" to get those above a user and then email them all.
    – powlo
    Feb 11, 2016 at 13:05

Edit-changing answer based on Sebastian's comment

If your role hierarchy is reasonably small, you could create a public group for each of the senior roles for a given junior role.

Then, you would evaluate the users role, and have a separate workflow for each role that sends an email alert to the appropriate public group.

Thus wouldn't scale to a large complex hierarchy, in which case code is prob best way to go.

  • The OP seems to want to send the email "up" the chain of command, not "down" (which is what subordinates mean) Feb 12, 2016 at 23:45
  • Ahh thanks I missed that. Tricky. Will have to think more.
    – gorav
    Feb 12, 2016 at 23:48
  • @mohammed do you want to just go up one level?
    – gorav
    Feb 13, 2016 at 0:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .