Intended for Salesforce developers, this document will provide the objects and parameters needed to integrate your Salesforce package with Adobe Sign.

Caution:

Be advised that the Adobe Sign for Salesforce objects may change in a future release. 

If you build a custom solution that depends on these objects, and they change, you may be required to update your customization.

Integration Guidelines

  • If you need to know when the agreement is fully signed, implement an Apex trigger on the echosign_dev1__SIGN_Agreement__c object, after or before update (depending on the use case and requirements). When the echosign_dev1__Status__c field changes to Signed or Approved or other final statuses, the agreement is completed. 
  • If you need to know when each individual signed PDF is inserted, if for example you need to get each intermediate signed PDF, then implement an Apex trigger on the Attachment or ContentVersion objects, after insert, and watch for a parent agreement and a name which ends in "- signed.pdf" or "- approved.pdf" or other final status
  • If you need to know when an individual recipient has signed or approved, implement an Apex trigger on the echosign_dev1__SIGN_Recipients__c object, after or before update (depending on the use case and requirements). When the echosign_dev1__Status__c field changes Signed or Approved or other final statuses, the recipient is completed.  
  • If you need to know when a particular event which is part of the signing process occurs, such as an agreement being sent for signature or a reminder being sent, a trigger can be created on agreement events object (echosign_dev1__SIGN_AgreementEvent__c) and check for the type of the event
  • The Final Agreement Status names for a completed agreement are: "Signed", "Approved", "Accepted", "Form-Filled", and "Delivered"
  • The Final Agreement Status names for a terminated agreement are: "Cancelled / Declined", "Canceled / Declined", "Expired"

Update Order

In v21 the order of updates has changed. Below is the sequence in which the agreement and its related objects are updated:

  1. Attachments 
  2. Recipients 
  3. Agreement (status and its other attributes)
  4. Agreement Events 
  5. Chatter Feeds 

Apex Services

Agreement Template Service

The agreement template service is exposed as a global Apex service by the managed package. This allows Apex code outside of the managed package to load agreements based on existing agreement templates. The class and all exposed methods are marked as global to allow such access.

The Apex service is exposed through the following invocation class: echosign_dev1.AgreementTemplateService

Note:

 Loading an agreement template with eSign Library Templates is currently not supported. Move the document templates to a Salesforce document library.

 

Methods

global

static Id load()

Loads an agreement using an agreement template marked as default and which has no master object type.

global

static Id load(String templateId)

Loads an agreement using the specified agreement template ID, which has no master object type.

 

global

static Id load(String templateId, String masterId)

Loads an agreement using the specified agreement template ID and the specified master record ID, whose type must match the master object type configured in the specified agreement template.

global

static Id load(String templateId, String masterId, Map<String,AgreementTemplateVariable> agreementTemplateVariables)

Loads an agreement using the specified agreement template ID and the specified master record ID, whose type must match the master object type configured in the specified agreement template. Also passes in the specified runtime variables as name value pairs.

 

 

Runtime Variables

The echosign_dev1.AgreementTemplateVariable global class has two global fields.

  • name : The variable name, which must match a runtime variable name configured in the agreement template.
  • value : The value of that variable which will be used during the template load. The value depends on where the variable was used. For example, for a recipient it has to be a contact, lead, or user record ID or an email. For a document variable, it must be an attachment record ID.

Result

Every method either return the ID of the newly created agreement record or throws an exception with a detailed error message if something went wrong during the load operation.

API Service

The Adobe eSign API template service is exposed as a global Apex service by the managed package. This allows Apex code outside of the managed package to invoke a set of Adobe eSign API's through these wrappers. The wrappers greatly simplify the API invocation because consumers do not need to create request and response data model. Also consumers do not need to handle the transformation of Salesforce data into eSign data models. Most of the complexity is abstracted from the consumer. For example, to send an agreement the consumer just passes in the agreement record ID, the service will handle querying it, extracting all of the relevant data, passing it on the API and parsing the result.

The class and all exposed methods are marked as global to allow such access.

  • v17 and below invokes SOAP API's
  • v18 and above invokes REST API's

The Apex service is exposed through the following invocation class: echosign_dev1.EchoSignApiService

Methods

global

static void cancelDocument(Id agreementId)

Cancels the agreement with the specified agreement ID.

global

static void delegateSigner(Id agreementId, String delegatedEmail)

Delegate signing to the provided email.

global

static void delegateSigner(Id agreementId, String delegatedEmail, String message)

Delegate signing to the provided email with the specified message.

global

static echsign_dev1.EchoSignApiService.DocumentInfo getDocumentInfo(Id agreementId)

Retrieves detailed information for the specified agreement ID.

global

static List getSigningUrls(Id agreementId)

Retrieves all signing URL's for the specified agreement ID.

global

static void removeDocument(Id agreementId)

Cancels the agreement with the specified agreement ID and deletes the agreement record in Salesforce (the agreement is not removed from the Adobe eSign account).

global

static void replaceSigner(Id replacementRecipientId)

Replaces the specified signer.

global

static void replaceSigner(Id replacementRecipientId, String message)

Replaces the specified signer with the specified message.

global

static echsign_dev1.EchoSignApiService.SendD ocumentResult sendDocument(Id agreementId)

Sends out the agreement with the specified agreement ID, returns the result with the document key and URL's.

global

static void sendReminder(Id agreementId)

Sends a reminder to the current signer for the specified agreement ID.

global static void updateAgreement(Id agreementId)  Updates the agreement with the specified agreementId

 

Inner Classes

global class DocumentHistoryEvent

Properties (2)

Access

Name

global

String eventType

global

String participantEmail

 

Constructors (1)

Access

Signature

global

DocumentHistoryEvent()

 

global class DocumentInfo

Properties (5)

Access

Name

global

Map<string,list> historyByEmail

global

Map participantsByEmail

global

Map participantsByName

global

String senderEmail

global

String status

 

Constructors (1)

Access

Signature

global

DocumentInfo()

 

global class ParticipantInfo

Properties (5)

Access

Name

global

String company

global

String email

global

String name

global

String status

global

String title

 

Constructors (1)

Access

Signature

global

ParticipantInfo()

 

global class SendDocumentResult

Properties (3)

Access

Name

global

String documentKey

global

Exception error

global

String url

 

Constructors (1)

Access

Signature

global

SendDocumentResult()

 

global class SigningUrl

Properties (3)

Access

Name

global

String email

global

String esignUrl

global

String simpleEsignUrl

 

Constructors (1)

Access

Signature

Global

 

Apex Batch Services

Exposes the main eSign agreement actions on a bulk level, allowing an operation to be performed on a set of agreements. This class implements the Salesforce Database.Batchable interface. It can process any number of records, which will be broken down into sets of 5 and processing each set as an individual transaction, which allows governor limits to be respected.

The Apex batch service is exposed through the following invocation class: echosign_dev1.EchoSignActionBatch

Parameters

The following parameters must be specified to initialize a batch operation.

A list of the agreement record ID's on which to perform the provided action. The action to perform, one of the following supported values:

  • Remind
  • Send
  • Cancel
  • Delete
  • Update

Current user session ID. Only required for an update action type.

Submitter user record, used to notify this user through an email once the bulk processing completes.

Usage Example

User submitterUser = UserInfo.getUserId();

EchoSignActionBatch batch = new EchoSignActionBatch( agreementIds, 'Remind', UserInfo.getSessionId(), submitterUser); syncProcessId = Database.executeBatch(batch, 5);

 

Agreement Template Batch

Takes in a SOQL query and an agreement template record ID. The query is executed to get a set of master object records, each of which is then run through the provided agreement template to generate an agreement record. This class implements the Salesforce Database.Batchable interface. It can process any number of records, which will be broken down into sets of 5 and processing each set as an individual transaction, which allows governor limits to be respected.

The record types returned by the SOQL query must match the provided agreement template master object type. For each record, the agreement template service is invoked.

The Apex batch service is exposed through the following invocation class:

echosign_dev1.AgreementTemplateBatch

Parameters

The following parameters must be specified to initialize a batch operation.

SOQL query to execute, must contain the record ID as a selected field. Any other field is optional.

Agreement template record ID, which will be used in conjunction with the master record ID to load an agreement.

Usage Example

String agreementTemplateId = [SELECT Id from echosign_dev1__Agreement_Template__c where Name = 'Default Template']; String soqlQuery = 'SELECT Id from Contact where Account.IsActive = true';

AgreementTemplateBatch batch = new AgreementTemplateBatch(soqlQuery, agreementTemplateId); syncProcessId = Database.executeBatch(batch, 5);

 

Agreement Template Service Batch

Takes in a list of master object record ID's and the master object type, which are then queried, and each of which is then run through the provided agreement template to generate an agreement record. This class implements the Salesforce Database.Batchable interface. It can process any number of records, which will be broken down into sets of 5 and processing each set as an individual transaction, which allows governor limits to be respected.

The master object type provided must match the provided agreement template master object type. For each record, the agreement template service is invoked.

The Apex batch service is exposed through the following invocation class:

echosign_dev1.AgreementTemplateServiceBatch

Parameters

The following parameters must be specified to initialize a batch operation.

  • List of master record ID's.
  • Master object name to query for the master records.
  • Agreement template record ID, which will be used in conjunction with the master records to load an agreement.

Usage Example

String agreementTemplateId = [SELECT Id from echosign_dev1__Agreement_Template__c where Name = 'Default Template'];

AgreementTemplateBatch batch = new AgreementTemplateServiceBatch(new List<Id>{'01p50000000HoMB'}, 'Contact', agreementTemplateId); syncProcessId = Database.executeBatch(batch, 5);

REST Services

Agreement Template Service

The agreement template service is exposed as a Salesforce REST web service by the managed package. This allows external systems outside of the Salesforce org to load agreements based on existing agreement templates. Please refer to the Creating REST APIs using Apex REST article for more details on how to access and invoke custom REST Apex services from within Salesforce. Invocations must provide a valid session ID for authentication and authorization.

The web service is exposed from the following URL:

https://<instance_name>.salesforce.com/services/apexrest/echosign_dev1/template/load/<template_id>?masterId=<master_id>&varName1=var Value1&varName2=varValue2

Note:

The instance name will vary depending on your org instance.

 

Template ID

The last part of the URL is the ID of the agreement template record in the current Salesforce organization which should be used to load the agreement. This part of the URL is optional. If omitted, the agreement template marked as the default will be loaded. If the template ID is omitted and no default agreement template ID exists, an error will be returned.

The template ID can be in the 15 or 18 character format.

Master ID

The masterId parameter specifies which master record should be used to load the agreement from the specific agreement template. This parameter is optional, but must be specified for any agreement template which specifies a master object type and references that master object in the template.

The template ID can be in the 15 or 18 character format.

Runtime Variables

Any additional parameters are used as runtime variables, as name value pairs, used to populate any runtime variables specified in the agreement template.

 

Result

The REST web service returns a LoadResult object which contains the following fields:

  • agreementId : If the agreement load operation was successful, this contains the ID of the newly created agreement record.
  • error : If there was any error during the loading of the agreement, this field will contain a detailed error message.

 

Background Service

The background service capability allows package consumers to invoke various actions on an agreement object by updating the Background Action (echosign_dev1 Background_Actions c) field to the corresponding value. Once the field value is changed from a blank value or another value to one of the following values, the action is kicked off from a trigger which is part of the eSign managed package.

  • Remind
  • Send
  • Cancel
  • Delete
  • Update

All of the actions execute in an asynchronous future mode, so the status will be stored in the Error field on the agreement.

 

Backward Compatibility Changes v21

  • The agreement status is now updated after the documents and recipients are updated
    • Prior to v21 the status was set before.
  • The Signed Agreement object (which stores the Image URLs) is now not inserted at all
    • Prior to v21 it was inserted after all of the other updates were completed
  • Maximum size of callout request or response is limited to 12MB for asynchronous Apex as per Salesforce governor limits: https://developer.salesforce.com/docs/atlas.en-us.210.0.apexcode.meta/apexcode/apex_gov_limits.htm
    • Documents larger than 12MB can not be fetched from Sign due to above limit.
  • Agreement event descriptions have changed. It now matches the description as returned by Sign API and with the audit reports.
  • The update process is now run as a native Apex batch process (which is an asynchronous process) within Salesforce
    • Before it was an update using API calls from outside of Salesforce
    • Triggers off these status updates which kick off async processes no longer work because Salesforce limits calling another async process from an already running async process
  • Prior to v21, the agreement attribute updates were split up into separate update calls, now agreement object is updated all in one transaction.
  • Prior to v21, failed agreements could be only retried by doing a manual update from within Salesforce
    • Now updates are more reliable as the Sign backend automatically retries failed events for a specified number of times.
  • Manual updates now update all aspects of agreements including the related objects.
  • Push agreements now run in async mode, same as regular updates and additional attributes are updated, the same as regular updates.
  • There are new settings introduced to enable disable updates of different aspects of the agreement.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy