1

I have seen some code example where dsfs objects are added to Salesforce and DocuSign pickup the data change and create envelopes accordingly.

public static void sendDoc(id propertyId){

        Property__c p  = [select id, name, Docusign_Template_Id__c, (select id, name from Leads__r) from Property__c where id=:propertyId];
        dsfs__DocuSign_Envelope__c newEnvelope = new dsfs__DocuSign_Envelope__c();
    newEnvelope.dsfs__Source_Object__c = propertyId;
    newEnvelope.dsfs__DocuSign_Email_Message__c = 'my new message';

    insert newEnvelope;
    System.debug(newEnvelope.id);
    If(!String.isEmpty(newEnvelope.Id)){

        dsfs__DocuSign_Envelope_Document__c envDoc = new dsfs__DocuSign_Envelope_Document__c();
        envDoc.dsfs__DocuSign_EnvelopeID__c = newEnvelope.Id;
        envDoc.dsfs__External_Document_Id__c = p.Docusign_Template_Id__c;
        envDoc.dsfs__SFDocument_Type__c = 'DSTemplate';
        envDoc.dsfs__Document_Order__c = 1;
        envDoc.dsfs__Document_Name__c = 'Signup Document';
        insert envDoc;

        list<dsfs__DocuSign_Envelope_Recipient__c> signers = new list<dsfs__DocuSign_Envelope_Recipient__c>();
        integer index = 1;
        for(Lead l : p.Leads__r){
            dsfs__DocuSign_Envelope_Recipient__c signer = new dsfs__DocuSign_Envelope_Recipient__c();
            signer.dsfs__DSER_LeadID__c = l.id;
        signer.dsfs__Salesforce_Recipient_Type__c = 'LEAD';
        signer.dsfs__RoleName__c = 'Signer';
        signer.dsfs__DocuSign_Signer_Type__c = 'SIGNER'; //CUSTOMER 1
        signer.dsfs__DocuSign_Recipient_Role__c = 'Signer '+index;
        signer.dsfs__DocuSign_EnvelopeID__c = newEnvelope.Id;
            signers.add(signer);

            index++;
        }

        insert signers;
    }
        update newEnvelope;
}

Nothing seems to happen - the records are written into the DB but no callouts or other DS contact looks to be made.

Has anyone got this working and can provide pointers here?

I know I can implement via the REST API but am looking for a quick (dirty?) solution.

Many thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.