• Home
  • Blog
  • DocuSign eSignature Integration with Salesforce Lightning Flow
DocuSign eSign Integration with Salesforce Flow

DocuSign eSignature Integration with Salesforce Lightning Flow

DocuSign is a company based in San Francisco, California that is considered by many to be the industry leader in electronic signature (e-signatures) technology. DocuSign’s software allows parties to sign contracts and other documents electronically rather than signing them with pen and paper. As a salesforce consultant in India, we use DocuSign to to sign contracts and other documents electronically. This eliminates the need for parties signing a contract to be physically present at the same location. The technology also provides important security protocols. Signed documents are uploaded and encrypted with a unique hash. The hash can later be compared to a document to ensure that no one has tampered with the contract or other uploaded document.

How to use DocuSign in flow with a custom button?

First of all, go to AppExchange and search for the DocuSign App.

Download and install it for all user

  1. DocuSign Configuration
    1. : Go to the app through the Nine dots icon or App launcher and search for DocuSign App Launcher and Select It.

    2. After selecting DocuSign, we will be able to see a Window like the below-given image and click “Sign up for free “.

    3. : After clicking on “Sign up for free”, the DocuSign Registration page will open, insert the correct information as per the requirement.
    4. After completing all steps a screen like the below given image is visible in the DocuSign Setup Tab.
    5. Go to ‘DocuSign Envelope Templates’ and upload the document which is needed to send for signature and click on the ‘Upload’ button.
    6. After uploading the document it will move to the next wizard for Recipients. There we need to Add Recipients to send Emails.
    7. After adding Recipients it will move to the next step Merge fields. So, Add Merge Field to set the salesforce field in the document if needed.

    8. In the ‘Place Fields’ step, we can customize the document just by dragging and drop of fields and signatures to the place we want.

    9. The ‘Options’ step will configure the templated by giving several options like Reminders that remind us to send emails on a particular date or time.
    10. In the ‘Custom Button’ step a button is created when we check the page layout checkbox, but in our scenario, a flow is called from the custom button so we can’t use the ‘Custom Button’ wizard. 

How to use DocuSign in the flow?

  1. First of all, create one class and Inviolable Method for calling flow action, the sample code is here.


    public class SendToReconstructions {
    public static List sendEnvelope(List record) {
    Reconstruction__c mySource = record.get(0);
    return Null;

    @future(callout = true)
    public static void sendEnvelopeInFuture(Id mySourceId) {

    public static Id createAndSendEnvelope(Id mySourceId) {
    dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
    new dfsle.Entity(mySourceId)

    Reconstruction__c rc = [SELECT id, contact__c FROM Reconstruction__c WHERE Id = :mySourceId LIMIT 1];

    Contact myContact = [SELECT Name, Email FROM Contact WHERE Id = :rc.contact__c LIMIT 1];

    dfsle.Tab mySignHereTab = new dfsle.SignHereTab()
    .withScale(1) // 1/2 scale
    .withRequired(true) // Signing is mandatory
    .withPosition(new dfsle.Tab.Position(
    1, // The document to use
    1, // Page number on the document
    500, // X position
    500, // Y position
    null, // Default width
    null)); // Default height

    // Create an anchor
    dfsle.Tab.Anchor myAnchor = new dfsle.Tab.Anchor(‘Acknowledgement’);

    // Create an Initial Here tab
    dfsle.Tab myInitialHereTab = new dfsle.InitialHereTab()
    .withRequired(false) // Signing optional
    dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
    new dfsle.Entity(rc.contact__c)
    .withTabs(new List { // Associate the tabs with this recipient
    myEnvelope = myEnvelope.withRecipients(new List { myRecipient });
    dfsle.UUID myTemplateId = dfsle.UUID.parse(‘438228d7-1c86-40c2-a37e-b7f855ee070d’);
    dfsle.Document myDocument = dfsle.Document.fromTemplate(
    ‘Services Framework Agreement’ );
    myEnvelope = myEnvelope.withDocuments(
    new List { myDocument }
    myEnvelope = dfsle.EnvelopeService.sendEnvelope(
    return myEnvelope.Id;

  2. Now to create flow go to Setup > Flow > New Flow > Auto launched Flow. Get records from objects as per the need

  3. Create one Variable to store the record id, which gets from the custom button URL

  4. Add a new element Apex Action and select the inviolable method class name and set the input value and select the variable name which was created in step 3 and click ‘Done’.

  5. Click ‘save as’ and Active the flow. Now we need to create a custom button that is when the user clicks on the button, Auto launched Flow is called and it sends an email to the current record. So, go to object manager and select ‘Buttons, Links, And Actions’, and set property like the below image.


  6. Now ­­­go to the page layout and set the custom button

  7. Now custom button is visible on the record page.