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
George Laird 29George Laird 29 

Approval process email alert question. Need Apex?

Hello All,

I've got an interesting use case here.  I've got an approval process built out on Opportunities.  One of the managers wants an email anytime something is approved or rejected but only if the Oppty was created by one of the people on her team.  Otherwise she doesn't want an email at all.  

Any ideas on how to do this?  In the approval process itself, I don't see a way to send an email alert based on a criteria.   I know that I could create some formula field like a checkbox to return 'true' if the record was created by someone on her team, but I don't see a way to fire of an Approval Action based off a criteria. 

So maybe a trigger then on approval?  If so, what object would by trigger be on?  

Thanks in advance everyone!
George


 
Best Answer chosen by George Laird 29
GauravGargGauravGarg
@George, 

Sobject Process Instance is internally stored as an Approval Process. Please go through the document on this particular object and you can identify all the answers. 

All Answers

GauravGargGauravGarg
Hi George,

Yes, you are absolutely correct. In the Approval process, we do not have the option to fire the approval process based on criteria, But we can fire the Approval process from Apex, Process Builder which allows checking custom conditions. 

#1: Apex:
In Apex, we can fire the Approval process after checking specific requirements/conditions. Please go through this link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm)

#2: Process Builder
Process Builder is much like a trigger (configurable) which gives us an option to
  • Check condition
  • Run-on specific event
  • Fire Approval Process
  • Call Apex Class and many more. 

For details go through this link (https://developer.salesforce.com/forums/?id=906F0000000kKJjIAM)
 

Hope this answered your question. 

For in-depth details you can directly contact me on skype: gaurav62990 or via email: gauravgarg.nmims@gmail.com

Thanks,

Gaurav Garg

 

George Laird 47George Laird 47
@GauravGarg, thanks!  What I'm wondering though is if I can write a trigger that fires when something is approved.  I don't want to fire the approval process off from apex.  What object would I need a trigger off if I want it to "listen" for when something is approved?
GauravGargGauravGarg
@George, 

Sobject Process Instance is internally stored as an Approval Process. Please go through the document on this particular object and you can identify all the answers. 
This was selected as the best answer