You need to sign in to do that
Don't have an account?
Approval Process not getting called Automatically while using Save&New Button
Hi
I called the Approvalprocess dynamically as soon as the record is created by using the code in the following method.
public pagereference updateTimeSheet(){
Timesheet__c getCurrentTimesheet = [select id,Comments__c,Project_Task__r.Assigned_To__c,Project_Task__r.CreatedById ,Timesheet__c.Project__r.ownerid,Approve__c,Approval_Status__c from timesheet__c where id=:this.id];
system.debug(getCurrentTimesheet);
User[] Approver = [select id from user where id=:getCurrentTimesheet.Project_Task__r.Assigned_To__c];
system.debug('!!!!!!!!!!!!!!!!!!!!!!'+Approver );
id[] uid = new id[]{};
uid.add(Approver[0].id);
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(getCurrentTimesheet.id);
app.setNextApproverIds(uid);
Approval.ProcessResult result = Approval.process(app);
update getCurrentTimesheet;
return null;
}
I Called the method on the Page..So that when the records are created,Approval process will be called Automatically..
Page :
<apex:page standardController="Timesheet__c" extensions="ApproveBillController" action="{!updateTimeSheet}"> </apex:page>
Issue is,When a Timesheet is created using Save button,then the approval process is getting called..
But,When we use Save&New button while creating multiple records..Then the Approval process is not getting called.
All Answers
Thanks for the Reply..
I Even used the Following Trigger..
trigger is working only on the Save Button ,but not on the Save&New.
Trigger Worked !!!!!!!
Thanks for the Reply.