+ Start a Discussion
pJabeenpJabeen 

Approval Process - Auto Approve using Trigger

HI

My problem is I have created a 2 step approval process for a custom object.Now, if the  second step is not approved in 2 days then it should get automatically approved. I couldnt find any workaround to get this done but when is was looking for answers everyone has been recommending to write a trigger. can any1 help me to write a trigger that can automatically approve. for eg.  

if status is "Pending with the Team Head" 
and its crossed a 2 days (created a check box to caculated the days)
then it should auto approve. 

I am not good with triggers and hence requesting if you can solve it for me.

Reallly appreciate your help on this.

Thanks in Advance
Jabeen
Sami ShakithSami Shakith
Hi Jabeen,

Trigger will not work in this case. You can go for scheduled class or time based workflow.
 
karthikeyan perumalkarthikeyan perumal
Hello, 

Batch Class :

That runs at regular interval and checks that if a record is older than 24hrs, approve the same. Here is ecample of approval of recording using apex http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_example.htm
Workflow + triggers :
you can use workflow time triggers to update a field in the record, then use trigger to identify the record and process the approval request.

hope this will help you. 

Mark it solved if its work for you
Thanks
karthik