Drawloop Button: Lock ‘Generate Document’ button until approval is given via an approval process


You would like Users to generate a document ONLY after the record has gone through an approval process.


After configuring the Salesforce approval process, create a custom button using the sample syntax below:

var test = sforce.connection.query("SELECT Id From ProcessInstance WHERE TargetObjectId ='{!Opportunity.Id}' AND Status = 'Pending' Limit 1");

if (test.size == 0) 
window.location.href = '/apex/loop__looplus?sessionId={!$Api.Session_ID}&eid={!Opportunity.Id}';

alert('Cannot Run DDP while record is LOCKED');

Scroll to top