[SalesForce] Associate the Docusign envelope to a custom object salesforce record

Has anyone successfully associated a docusign envelop sent in REST API to a custom object? This post "Attaching a visualforce page rendered as PDF to Docusign email" showed how to associate envelop to a standard object such as opportunity.

DocuSignAPI.CustomField field = new DocuSignAPI.CustomField (); field.Name = '##SFOpportunity'; field.Value = opportunity.Id;

What would be the field name for a custom object?

Best Answer

So Walter answered it, and mpaler went into behind the scene action. I guess i will just write some code.

//create the envelope
esdsext.DocuSignAPI.EnvelopeInformation envelope = new esdsext.DocuSignAPI.EnvelopeInformation();
envelope.Subject = 'Envelope Subject' ;     
envelope.EmailBlurb = 'Email Blurb';

//use custom field to store the id of the record that initiated the transaction    
envelope.CustomFields = new esdsext.DocuSignAPI.ArrayOfCustomField();
envelope.CustomFields.CustomField = new esdsext.DocuSignAPI.CustomField[2];
esdsext.DocuSignAPI.CustomField myCustomField = new esdsext.DocuSignAPI.CustomField();
myCustomField.Name = 'DSFSSourceObjectId'; //this is what walter and mpaler talked about
myCustomField.Value = <Id of the custom object record>; //for example, pass the id of current record via VF page, and write this line as myCustomField.Value = my_custom_Object.Id;
myCustomField.Show = 'False';
myCustomField.Required = 'False';
myCustomField.CustomFieldType = 'Text';
envelope.CustomFields.CustomField[0] = myCustomField;

//after this, do other stuff, like mention recipients, template, etc and send the envelope
Related Topic