You need to sign in to do that
Don't have an account?

How do i set Approver email in Approval Processing Class ?
Hi all,
I have created an Approval Process on Case object and i have select Approver option manully.
I have one trigger that trigger the Approval process but i am unable to findout any Option or Method for assigning Approver for Approval process.
Please let me know if any one has any idea?
-- Deepak
This worked for me. I have some additional code for routing the approval request to appropriate user based on some condition.
//Submitting lead for approval Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('New Deg request submitted for approval'); req1.setObjectId(lead.id); // Submit the approval request for the lead // req1.setNextApproverIds(new Id[] {UserInfo.getUserId()}); ID elect = [select id from user where username='abcd@aol.com' limit 1].id; ID infdba = [select id from user where username='infa@test.com' limit 1].id; List<user> drID = [select Id from user where username='drid@test.com' limit 1]; List<account> apprID = [select Id,ownerId from Account where id=:Customer.id limit 1]; //Assign system owned accounts to Design Reg PM if (apprID[0].ownerId == elect || apprID[0].ownerId == infdba) { req1.setNextApproverIds(new ID[] {drID[0].id}); } else { req1.setNextApproverIds(new ID[] {apprID[0].ownerId}); } Approval.ProcessResult result = Approval.process(req1); }
All Answers
I have same issue. Not much experience with apex. Please find my code below. This is throwing an erorr below.
Save Error: Expression of type Approval.ProcessWorkItemRequest has no member named setNextApproverIDs
Shoudn't this be calling setNextApproverIds from it's parent class?
//Submitting lead for approval Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitting new DR request for approval.'); req1.setObjectId(lead.id); // Submit the approval request for the lead Approval.ProcessResult result = Approval.process(req1); Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest(); req2.setComments('Approving DR request.'); req2.setAction('Approve'); string tt = req2.getWorkitemId(); // req2.setNextApproverIds(new Id[] {UserInfo.getUserId()}); req2.setNextApproverIds='900530000000oigU';
Hi,
Were you able fix this? I am in the same situation. Getting the Error "Approval.ProcessSubmitRequest has no member named ".
Any thoughts?Please share...
This worked for me. I have some additional code for routing the approval request to appropriate user based on some condition.
//Submitting lead for approval Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('New Deg request submitted for approval'); req1.setObjectId(lead.id); // Submit the approval request for the lead // req1.setNextApproverIds(new Id[] {UserInfo.getUserId()}); ID elect = [select id from user where username='abcd@aol.com' limit 1].id; ID infdba = [select id from user where username='infa@test.com' limit 1].id; List<user> drID = [select Id from user where username='drid@test.com' limit 1]; List<account> apprID = [select Id,ownerId from Account where id=:Customer.id limit 1]; //Assign system owned accounts to Design Reg PM if (apprID[0].ownerId == elect || apprID[0].ownerId == infdba) { req1.setNextApproverIds(new ID[] {drID[0].id}); } else { req1.setNextApproverIds(new ID[] {apprID[0].ownerId}); } Approval.ProcessResult result = Approval.process(req1); }