Overview:- This blog is about integrating Adobe eSign to Salesforce using Apex.
Audience: Engineering
Often times Contract management, Order management, and many other applications on the Salesforce platform need signature capabilities to adhere to compliances, to streamline business processes, or to increase productivity. While Salesforce does not have a signature module feature out of the box for such applications today, the Salesforce development ecosystem has AppExhcange products such as Adobe eSign, DocuSign, Conga etc that can address the need. The blog primarily focuses on Adobe eSign integration with Salesforce via APEX.
Adobe’s eSign is an AppExchange product that can be easily installed and integrated into a business flow. The product comes with configuration options that allow customizing the flows, defining rules, data mapping etc. It adheres to security standards and help businesses streamline their document management processes, enhance customer experience, increase productivity and improve compliance.
Salesforce To Adobe integration process.
Here are the detailed steps to install and integrate the Adobe Sign package to a Salesforce org –
-
- The first step is to set up an Adobe developer account using this link. Adobe also provides a free trial account for 30 days. Per user the license version cost starts at $34.
- Next is to install Adobe Sign managed package in your salesforce org.
- Once installed, go to the Adobe Acrobat Sign Admin tab and link your Adobe developer account with your Salesforce org.
- The integration process is as simple as that. Further admin-level configuration can be done from the Access Adobe Acrobat Sign Account Management Console link available in the Admin tab. Also, the users and groups setup can be done based on the users who leverage the Adobe features in Salesforce.
Adobe provides configurable templates where the recipients, attachments, data mappings and rules can be configured. This can be achieved using declarative approach or a complete custom apex solution.
Also for standard objects such as accounts and opportunities, Adobe offers the Send for Signature button which can be directly added to the page layouts. Refer to the official Adobe Acrobat Sign for Salesforce: Developer Guide for details.
Here we will try to keep the templates configurable to minimize code dependency and to maintain multiple templates which can have different configurations based on different use cases.
Setting up of Adobe Agreement Templates:
- First, create a lookup field for your custom object in the Agreement(echosign_dev1__SIGN_Agreement__c) object.
- The next step is creating an Agreement Template, get back to the Adobe Application -> Agreement Templates tab and create New.
- To associate the agreements created using the templates to your records, select the custom/master object from Salesforce Object.
- For mapping any field data from the master object to agreements, select Map data into agreement fields. Here we need to map the master object record id to the agreement object lookup field created in Step 1.
- Enable the Auto Send checkbox.
- To get the document attached dynamically with the agreement, go to the next tab ATTACHMENT -> Choose Document Source -> Runtime Variable
-> insert some variable name -> Add. - In the next tab RECIPIENTS, we can specify the signer, approver or form filler who will receive the documents on their email address.
There can be multiple recipients and if the receiver has a Contact, User, or Lead record which is linked with our master object record with lookup, select Add recipient from object or run-time variable -> Look Up Based on Master Object Field -> Recipient Type: Contact -> select Source field from master object -> Save. Let’s say that the recipient doesn’t have any Contact, User or Lead record, but we have the email address that the apex can pass. For this scenario Add the recipient from the object or run-time variable -> Runtime Variable -> insert some Variable Name -> Recipient Type: Email -> Save. - Similarly, we can add as many recipients as required and declare the runtime variables based on the use case.
All the runtime variables which are being referred to in the template need to be passed from Apex. Moreover, it will be clear once we go to Apex implementation. - In the next tab DATA MAPPINGS, we can specify if there are any merge mappings or data mappings. Merge Mappings can be used to merge salesforce field values to the agreement before sending for signature. Data Mappings are used to map inputs from the signed agreements back into salesforce like attaching the signed agreement to the master record. Go to the Data Mapping tab and create a record first and add the file mappings or fields mappings based on the requirement and we can refer to the same data mapping record in the agreement template. Similarly, it goes for Merge Mappings.
- We can also add rules based on the requirement and save the agreement template which will be referred to in Apex.
Sending Agreements from Apex:
Sending the agreements for eSign directly from Apex, Adobe managed package provides Agreement Template Service which is exposed as a global Apex class.
There are several methods available in the echosign_dev1.AgreementTemplateService global apex class which our custom apex solution can invoke and is explained in the Adobe developer guide in brief.
Now that we have the account, template and data mapping ready, let’s get into more detail on how we can implement taking an example of the static load() method.
The following runtime variables were added while creating the Agreement Templates:
myAttachmentVariable | Pass the document’s content version id to the agreement |
myRecipientVariable | Pass recipient 1 email address to the agreement |
Though Adobe has made it so easy by providing the Apex template service and several configurations, the documentation part on the developer guide makes it a bit difficult to understand how to implement it in real time.
Let’s jump to the final part of how the code would look like:
-
- Create a map with the runtime variables as the key and the value as a map of the runtime variable as the key and the value of that variable which will be used during the template load. For example, a recipient variable, can be a contact, lead, or user record ID or an email. Similarly, for an attachment variable, it will be the content version Id.
|
-
- This is my theory of how the load() method works, and I believe it works works well. But maybe the first string was expecting some different key for which Adobe did mention just this i.e. not much:)
- Finally, call the Adobe load() method and pass the template id, master object record id and the AgreementTemplateVariable map as parameters.
- This is my theory of how the load() method works, and I believe it works works well. But maybe the first string was expecting some different key for which Adobe did mention just this i.e. not much:)
|
- This will create a signed agreement with the document attached which will be auto-sent to the recipient for signature on the email address.
- Same can be verified from the Agreements tab which will have the new agreement which was sent with Out for Signature status and will show as a draft status in case of any issues. Once signed, the status changes to Signed and all the parties involved receive the signed document by email.
- The signed document gets attached back to the agreement record in Salesforce and will even display attached to the custom object record in case the data mappings are added to the template.
There are many more configurations, declarative approaches and custom apex solutions provided by Adobe Sign for Salesforce and are available in the Adobe developer guide.
Thanks!
References –
Adobe Official Developer Guide