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
Siddharth Birari.ax1164Siddharth Birari.ax1164 

Configuring Email Alert Recipients

Hi all,

 

I have developed a workflow with Time-Dependent Workflow Actions to send Emails.

 

There are no issues at all in execution of Workflow, but the thing is I want to configure the recipients in my Time-Dependent Workflow Actions (Email Alert).

 

Email Recipients to be configured

 

1) Record Owner

2) Immediate Manger of Record Owner in Role hierarchy

3) Immediate Manger of person(user) referred at point 2

and in Role hierarchy and so on

 

So far i am able to configure the recipient to Record Owner only

 

I tried with configuring recipient to 'Role' but in that case all the users assigned to that role receive the mail, which is not required.

 

Please help

 

Thanks in Advance

 

Best Answer chosen by Admin (Salesforce Developers) 
Andy BoettcherAndy Boettcher

I'm not sure what declarative options are available...being as dynamic as you're looking 

 

I just ran through a few things that were hitting me off the top of my head...

 

APEX to modify the workflow action?  Nope - you can't query time-based workflow actions

 

Workflow off of workflow-updated fields?  Nope - Salesforce doesn't allow that kind of recursion.

 

(Crazy option) - you could create a Custom Object and via a Trigger, create records in there that mimic the Time Based Workflow logic.  Then, you would have to have a Scheduled APEX job running on a nightly basis to query that new custom object to send emails as needed.  Through APEX, you can query through the Role heirarchy and store the emails / users you want to email...

 

The "crazy option" would work, but that's a lot of coding.  =)

 

-Andy

All Answers

Andy BoettcherAndy Boettcher

I'm not sure what declarative options are available...being as dynamic as you're looking 

 

I just ran through a few things that were hitting me off the top of my head...

 

APEX to modify the workflow action?  Nope - you can't query time-based workflow actions

 

Workflow off of workflow-updated fields?  Nope - Salesforce doesn't allow that kind of recursion.

 

(Crazy option) - you could create a Custom Object and via a Trigger, create records in there that mimic the Time Based Workflow logic.  Then, you would have to have a Scheduled APEX job running on a nightly basis to query that new custom object to send emails as needed.  Through APEX, you can query through the Role heirarchy and store the emails / users you want to email...

 

The "crazy option" would work, but that's a lot of coding.  =)

 

-Andy

This was selected as the best answer
Siddharth Birari.ax1164Siddharth Birari.ax1164

Thanks a lot Andy. Actually i am looking out to avoid the code part so as to make it configurable.

But if i am left with no option but coding, i guess, your suggestion will work.

Andy BoettcherAndy Boettcher

Yeah - I know and I hear ya.  The mantra of "Always do it Declaratively before Programmatically" is tried and true - going via the UI is always preferred.

 

You COULD try and make a large convoluted network of Public Groups and do some Workflow updates to populate a field that way...but that could get unmanagable rapidly...

 

-Andy

Siddharth Birari.ax1164Siddharth Birari.ax1164

As of now, I have created a trigger on my custom object that contains the logic to acheive the desired output.

 

Probably this code can be avoided after 'Cross object workflows' from Spring'12 Release.