docusign update parent field on complete

2019-08-09 01:35发布

I am new to docusign integration with salesforce. I am following a simple flow of

  1. User logs into sfdc
    1. User goes to an object A and clicks the custom button (exactly same one as in documentation) selects a template and sends to user X.
    2. The receiver X will sign and send it back. My question is - after step 3, is there any way to update a picklist field in the object A indicating that the document is signed and received.

I do not want to do a trigger on document status and when I tried process builder, cannot see the parent picklist field.

So, I want to know if docusign has any feature to solve my problem.

Thanks

KR

1条回答
做自己的国王
2楼-- · 2019-08-09 01:56

The DocuSign for Salesforce (DfS) app on the App Exchange is an end product (ie. end-user product). If it's current feature set does not solve all of your business needs then you can always do an API integration and use the DocuSign Connect module.

Using DocuSign Connect you can setup an external http listener where real time status/event updates are sent and can be parsed. At that point you can write whatever logic you need to do inside or out of Salesforce. For more info on DocuSign Connect see this here.

Otherwise if you want to use in conjunction with DfS, this can be done only by trigger because

  1. Workflows won’t help because workflow can’t update related (via Lookup field) object.
  2. Process builder also won’t help because of the same issue (can’t update related object).
  3. Formula fields won’t help because DocuSign Status to Salesforce object is 1 to Many relationship.

The only correct solution is a trigger (it’s very simple, 10 lines of code, just replace my TODOs with your info):

trigger UpdateOpportunityOnEnvelopeCompleted on dsfs__DocuSign_Status__c (after update)
{

    // get a set of all completed docusign statuses with opportunities
    Set<Id> opportunityId = new Set<Id>();
    for(dsfs__DocuSign_Status__c  status : Trigger.new) {
       if (status.dsfs__Opportunity__c != null && status.dsfs__Envelope_Status__c== 'Completed') {  // TODO: Replace dsfs__Opportunity__c with the object you want to update, say dsfs__Contact__c or dsfs__Lead__c
           opportunityId.add(status.dsfs__Opportunity__c);                                                                                     // TODO: Replace dsfs__Opportunity__c with the object you want to update
       }
    }

    // retrieve these opportunities
    // TODO: Replace DeliveryInstallationStatus__c with the field you want to update, replace Opportunity to your object name, ex: Contact or Lead
    List<Opportunity> opportunities = [SELECT Id, DeliveryInstallationStatus__c FROM Opportunity WHERE Id IN :opportunityId];

    // update these opportunities
    for(Opportunity o : opportunities) {                  // TODO: Replace Opportunity with your object name
        o.DeliveryInstallationStatus__c = 'Completed';    // TODO: Replace DeliveryInstallationStatus__c with the field you want to update , replace 'Completed' with field value you want to set
    }
    update opportunities;
}
查看更多
登录 后发表回答