I need some help.
I have created the following button , however when i click on the button i get the following .
This is the class, which i want the button to call. Anyone have any ideas why this is not working ?
global class initiateapproval {
public String mysw {get; set;}
Webservice static String initiateswapproval(String mysw) {
//change Campaign__c to your sObject
Campaign sw = new Campaign(Id=mysw);
//make sure you add the custom field Submitted for Approval on your object as this is what you
//will use as your approval process entry criteria.
//This is the approval process entry I used: Entry Criteria (Campaign: Approved Date EQUALS null) AND (campaign: Submitted for Approval EQUALS TODAY)
sw.Submitted_for_Approval__c = System.Now();
update sw;
// Create an approval request for the record
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval automatically');
req1.setObjectId(mysw);
Approval.ProcessResult result = Approval.process(req1);
return null;
}
}