You need to sign in to do that
Don't have an account?
Dean Rourk 2
apex trigger for approval process
I keep getting a compile error: Error: Compile Error: Method does not exist or incorrect signature: [Approval.ProcessSubmitRequest].setNextApproverIds(Id)
Eventually I will not hard code the user name 'john Taylar' and get it from the object.
Has anyone been able to get this to work.
trigger SDRStartApprovalProcess on SDR__c (after update) {
for( id aId : Trigger.newMap.keySet() )
{
if( Trigger.oldMap.get( aId ).Account_Owner_id__c!= Trigger.newMap.get( aId ).Account_Owner_id__c )
{
// do something here because your field has changed
List<User> users = [select Name from User where Name= 'John Taylor'];
id approver= users.get(0).Id ;
//Approver = userMap(Trigger.newMap.get( aId ).Account_Owner__c).Id
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(aid);
app.setNextApproverIds(approver);
Approval.ProcessResult result = Approval.process(app);
}
}
}
Eventually I will not hard code the user name 'john Taylar' and get it from the object.
Has anyone been able to get this to work.
trigger SDRStartApprovalProcess on SDR__c (after update) {
for( id aId : Trigger.newMap.keySet() )
{
if( Trigger.oldMap.get( aId ).Account_Owner_id__c!= Trigger.newMap.get( aId ).Account_Owner_id__c )
{
// do something here because your field has changed
List<User> users = [select Name from User where Name= 'John Taylor'];
id approver= users.get(0).Id ;
//Approver = userMap(Trigger.newMap.get( aId ).Account_Owner__c).Id
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(aid);
app.setNextApproverIds(approver);
Approval.ProcessResult result = Approval.process(app);
}
}
}
You need to pass list of users in setNextApproverIds.
Like this
one more thing this code only works if you have any Applicable Approval Process.
Regards
Subhash