Einstein Next Best Action: How to Invoke DocuSign as an Action

Custom buttons created by the DocuSign for Salesforce app do not work with Einstein Next Best Action because the buttons invoke the DocuSign API via a Visualforce page. If you want your users to have the ability to select an action that allows them to send a document for signature from the Einstein NBA section, you will need to configure a work around. Watch the video below from Blu Tiger Academy that contains step-by-step instructions to setup the necessary configurations. This video assumes you understand how to configure Predefined Recommendations. If you need a tutorial on how to setup Einstein NBA from scratch, check out our resources below.

Please note: Since this solution contains apex classes, you will need to do these configurations in a sandbox environment and deploy them to production.

Blu Tiger Academy Other Video Resources on Einstein Next Best Action:

High Level Steps to Follow

  • Create the two apex classes below
  • Create a screen flow that will use the invocable Apex action you created called DocuSignSendingURLforFlow
    • Name of Flow = Opportunity NBA | DocuSign Proposal
    • Description = This screen flow is used in Einstein Next Best Action recommendations to show sending DocuSign Proposal as a Recommendation.
  • Use Navigate Anywhere to control the user's finish location -> route them to the DocuSignSendingURL formula below.
  • Create a Recommendation record
  • Upload Asset File
  • Upload image to Recommendation record
  • Create/update your Recommendation Strategy flow with the new Recommendation.

Apex Class - DocuSignSendingURLforFlow

 	
public class DocuSignSendingURLforFlow {

    @InvocableMethod(label='Get DocuSign Sending URL' description='Retrieve the URL for DocuSign Sending page with confirmation token.')
    public static List getURL() {
        
        List resultList = new List();
        
        // Use PageReference to get the URL of the DocuSign Sending page
        PageReference docusignPageRef = Page.dfsle__Sending;
        docusignPageRef.setRedirect(true);
        String DocuSignSendingURL = docusignPageRef.getUrl();
        
        // Remove unnecessary parameters from the URL
        DocuSignSendingURL = DocuSignSendingURL.substringBefore('&common.udd.actions');
        
        resultList.add(DocuSignSendingURL);
        return resultList;
    }
}

Apex Class - DocuSignSendingURLforFlowTest

 	
@isTest
private class DocuSignSendingURLforFlowTest {

    @isTest
    static void testGetURL() {
        
        // Call the getURL method
        List resultURLs = DocuSignSendingURLforFlow.getURL();

        // Perform assertions
        System.assertEquals(1, resultURLs.size(), 'Expected only one URL in the result list');
        
        // Validate that the URL is not empty
        String resultURL = resultURLs[0];
        System.assertNotEquals(null, resultURL, 'URL should not be null');
    }
}

Formula for Flow - forDocuSignSending URL

{!DocuSignSendingURL} & '&sId=' & {!recordId} & '&sendingExperience=' & 'null' & '& isEmbedded=' & 'false' & '&templateId=' & {!Get_DocuSign_Envelope_Template.Id} & '&recordId=' & {!recordId} & '&title' & 'DocuSign Proposal'

For any questions, comments, concerns – let us know in the comment section below!
We would love to hear from you!

Share This Story, Choose Your Platform!

About the Author

Cheryl Fernandes

Cheryl is a certified Salesforce Application Architect and is the Founder and Lead Salesforce Consultant at Blu Ninjas. She has been working with Salesforce for 12 years and has helped companies in financial services, insurance and beauty industries implement solutions on the platform. Flow is her favorite Salesforce declarative tool, it is a game changer for anyone who does not know how to code.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top