简体   繁体   中英

Salesforce DocuSign Integration

Use Case - Salesforce Docusign implementation:

We have Parent and child object in salesforce where Parent have authorize signer and Relationship Manger email information and their each child object have document which we need to sign by authorize signer and relationship manger.

We need to send all the child object documents in single envelope. And when the signing ceremony completed we need to attach respective signed documents to their respective child records.

Currently, we can planning to do through Apex Toolkit or DocuSign rest API.

Example: Authorized signer and RM present on account record. And each contact associated with account having document which are attached by Contact person. Account owner should have button where it should fetch all the document from related contact, create envelope, should tagging the signature on each document and able to send to authorized Signer and RM.

Authorized Signer should received all the document with in single envelope. They signed all the document. Once Signed by them all the signed document should go back to respective contact.

Note. Business wants to see all the Recipients status and document sent to end user in salesforce as well.

Can you please provide input on this and share some sample as per our use case.

Thank You!

The flow here would be to pull the documents with DocumentService.getLinkedDocuments and then set up anchor tabs. If you want to send multiple documents, you'll need to set the Anchor Population Scope to Document. If docs are numbered in the order of the list 1, 2, 3. You will use.withOptions for the writeBack. Example can be found here: https://www.docusign.com/blog/developers/whats-new-summer-21-apex-toolkit And a sample code (except for the writeback part):

//Find your contact to add
Contact myContact = [SELECT Id, Name, Email FROM Contact WHERE Name = 'Snow Beard' LIMIT 1];
//This sets tab as an anchor tab. If using this with multiple documents, 
// Ask customer support to set Account Setting Anchor Population Scope to Document.
dfsle.Tab hereTab = new dfsle.SignHereTab()
        .withScale(1) // 1/2 scale
        .withRequired(true) // Signing mandatory
        .withDataLabel('SignHereMeHardy')
        .withAnchor(
                new dfsle.Tab.Anchor(
                        'Anchor1', // Anchor string
                        true, // allow white space in anchor string
                        true, // Anchor string is not case sensitive
                        'right', // Horizontal alignment in relation to the anchor text
                        true, // Ignore if the anchor text is not present in the document
                        true, // Must match the value of the anchor string in its entirety
                        'pixels', // Unit of the x and y offset properties
                        10, // X offset
                        10 // Y offset
                )
        )
        //This places the tab on the first docunent in the list on page one. Requires DocuSign Support to set Anchor Population Scope to Document.
        .withPosition(
                new dfsle.Tab.Position(
                        1, //Document id matches order of documents
                        1, //Page id
                        null,
                        null,
                        20,
                        20
                )
        );
        
//use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource
        (
        myContact.Name, // Recipient name
        myContact.Email, // Recipient email
        null, //Optional phone number
        'Signer 1', //Role Name. Specify the exact role name from template if using a template or use Default 'Signer 1'
        new dfsle.Entity(myContact.Id)    //source object for the Recipient
        )
        .withTabs(new List<dfsle.Tab> { // Associate the tabs with this recipient
        hereTab
        });
        
Opportunity myOpportunity = [SELECT Id FROM Opportunity WHERE Name = 'Sailcloth' LIMIT 1];
        
//This pulls all the documents from the Opportunity Object and adds them to documents list
List<dfsle.Document> documents = dfsle.DocumentService.getLinkedDocuments
        (
        ContentVersion.getSObjectType(),
        new Set<Id>{myOpportunity.Id},
        false
        );
        
// Create an empty envelope.
// This shows how to pull documents from an object in Salesforce. In this case an Opportunity
dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(new dfsle.Entity(myOpportunity.Id))
        .withRecipients(new List<dfsle.Recipient> { myRecipient })
        .withDocuments(documents);
        
// Send the envelope
try {
    dfsle.EnvelopeService.sendEnvelope(myEnvelope, true);
    } catch (dfsle.APIException ex) {
        system.debug(ex);
            if (ex.error.code == dfsle.APIErrorCode.CONSENT_REQUIRED) {
    // user is a valid member of the DocuSign account, but has not granted consent to this application
    } else {
    // handle other errors
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM