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
dineshkumardineshkumar 

Apex approval process:please guide me

I have a site where a user can create a new record and the goal is that this user can select their first approver from a lookup field.  I have the first step in the approval process set to "Let the submitter choose the approver manually" and I have already created a trigger that automatically submits a record for approval when created. I am attempting to use the setNextApproverIds method to pass in the approver from the form but I'm not sure how to get the selected users ID. Any help is appreciated.
trigger requestSubmit on Request__c (after insert) {

for (Request__c r : trigger.new) {
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(r.id);

app.setNextApproverIds(.profileID);

Approval.ProcessResult result = Approval.process(app);
}
}
please help me.........