An approval process is an automated process which can be used to approve/reject record updates. A record can be submitted for approval request from related list "Approval History". Once a records is submitted it goes for approval to a specified approver. This is a manual process where in every record should be individually sent for approval.
How about doing this using apex? Sending the record fro approval from trigger? Salesforec provides number of method for handling approval processes in apex.
Let us submit a record for approval process from trigger in an example below.
Lets say you have a approval process named "Account Owner Approval". You can create a approval process by navigating to following:
set up --> create --> approval process
Trigger to submit a account record for approval if its annual revenue is less then 2000
How about doing this using apex? Sending the record fro approval from trigger? Salesforec provides number of method for handling approval processes in apex.
Let us submit a record for approval process from trigger in an example below.
Lets say you have a approval process named "Account Owner Approval". You can create a approval process by navigating to following:
set up --> create --> approval process
Trigger to submit a account record for approval if its annual revenue is less then 2000
1
2
3
4
5
6
7
8
9
10
| trigger Call_AprovalProcess_In_Trigger on Account (before insert, before update) { for (Account acc:trigger. new ){ if (acc.AnnualRevenue < 2000){ approval.ProcessSubmitRequest aprlPrcs = new Approval.ProcessSubmitRequest(); aprlPrcs .setComments( 'Submitting record for approval.' ); aprlPrcs.setObjectId(acc.id); approval.ProcessResult result = Approval.process(aprlPrcs); } } } |
No comments:
Post a Comment