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
BenPBenP 

java button to call approval process

I have a little java button that checks a few items before changing the status via a trigger.  What I'd like to do is keep the checks in place, but at the end submit the item to my approval process.  Problem is, I don't know how to call an approval process via java script.  Can anyone point me in the right direction?  I'm not a developer, but am not afraid to put in the effort.

 

 

if('{!SVMXI__Parts_Request__c.Status__c}'=='Submitted'){
alert('This Sales Order is already submitted to QAD');
}
else if('{!SVMXI__Parts_Request__c.Status__c}'=='Complete'){
alert('This Sales Order is already submitted to QAD');
}
else if('{!SVMXI__Parts_Request__c.Status__c}'=='Processing'){
alert('This Sales Order is already submitted to QAD');
}
else if('{!SVMXI__Parts_Request__c.Total_parts_line__c}' <=0){
alert('There are no line items to submit');
}
else{
document.location.href="/apex/SVMX_PRStatusUpd?id={!SVMXI__Parts_Request__c.Id}";
}

 

 

kingkong94538kingkong94538

The workflow approval process is fired automatically (based on the configurations) like triggers. I don't think the approval process can be called from java script or trigger. The reason I think it's not possible is because how would you get the control from the approval process with in java script.

 

I'd rather implement such requirement in a Visual Force page and would program the approval process logic in some class - just a thought :D

 

Thanks!

BenPBenP

Working this into the button will call the approval process.

if ((Modal.confirm && Modal.confirm('Once you submit this record for approval, you might not be able to edit it or recall it from the approval process depending on your settings. Continue?')) || (!Modal.confirm && window.confirm('Once you submit this record for approval, you might not be able to edit it or recall it from the approval process depending on your settings. Continue?'))) navigateToUrl('/p/process/Submit?id={!Team_Update__c.Id}&retURL=%2F{!Team_Update__c.Id}');

 Credit to James Sullivan.