Drawloop Button: Grab attachment with specific name for generated document package


You only want Users to be able to generate a document when an attachment with a specific name exists for that record. Also, the attachment should be included in the generate document package.


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

var documentIds = new Array(); 
var documents = sforce.connection.query("SELECT Id FROM Attachment WHERE ParentId = '{!Contact.Id}' AND Name LIKE '%Invoice%'"); 
if (documents && documents.size > 0) { 
for (var i = 0; i < documents.size; i++) 
documentIds.push(documents.records[i] ? documents.records[i].Id: documents.records.Id); 
alert('Please add a document to this Contact.');

Scroll to top