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
LIM AI KHOONLIM AI KHOON 

Custom button to execute a Approval process

Hi, currently when my user click on approve/reject button, it will bring user to a link from flow builder. Once user click the link, it will redirect user to approval page (process approval). Is it possible if the button is directly bring user to approval page (approval process) without go to a page from flows builder?

Please let me know if you need more clarification on this.

Thank you :-)
AnudeepAnudeep (Salesforce Developers) 
Are you using the out-of-the-box Flow Core Action: Submit for Approval?
 
LIM AI KHOONLIM AI KHOON
It is not button submit for approval. It is a button to approve or reject application. Kindly refer my attachments. From page 1, user need to click the highlighted button to go to 2nd page (flows). Then, from page 2, user need to click the highlighted text (still in flow) to go to 3rd page (approval process). So now, it is possible to make from 1st page go to 3rd page? If yes, may I know how can I do that?

User-added image User-added imageUser-added image
LIM AI KHOONLIM AI KHOON
first you need to create a custom button field, choose onclick javascript as content source. Then you can paste this code. Change according to your requirement.

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

var result = sforce.connection.query("SELECT Id FROM ProcessInstanceWorkitem WHERE processInstance.TargetObjectId='{!objectName__c.Id}'");

var approvals = result.getArray("records");

if(approvals != undefined && approvals.length > 0) {
var approvalID = approvals[0].Id;
window.open('/p/process/ProcessInstanceWorkitemWizardStageManager?id='+approvalID);
}
else {
alert("There are no approvals pending.")
}