0

I have DocuSign set up to send from Quotes within Salesforce. However, once the document has been completed, I would like the Completed documents to be attached to the Opportunity record that is the parent of the Quote object.

I have tried configuring the Connect settings within DocuSign Admin but currently having no luck.

If I want to update the documents to the Opportunity, I don't have a field on the Opportunity that matches a reference on the Envelope as the Envelope just has the Quote details and there can be multiple Quotes for 1 Opportunity so I can't get this ID on the Opportunity level.

Has anyone had any luck with this previously?

1

DocuSign for Salesforce supports attachment of completed documents to the parent object:

To move the attachment from the parent object to that object's parent, you can create a trigger on the Attachment object:

trigger AttachmentTrigger on Attachment(after insert){

    Set<Id> parentIds = new Set<Id>();
    List<Attachment> quoteAttachments = new List<Attachment>();

    for(Attachment a : trigger.new) {
        // Pull attachments only related to Quotes
        if(a.ParentId.getSObjectType() == Schema.Quote.getSObjectType()){
            quoteAttachments.add(a);
            // Get the Quote Ids
            parentIds.add(a.ParentId);
        }
    }

    // Query for Quote Opportunity Ids
    Map<Id,Quote> quotes = new Map<Quote>();
    for(Quote q : [SELECT OpportunityId FROM Quote WHERE Id IN :parentIds ]){
        quotes.put(q.Id,q);
    }    

    // Change Parent Id on Attachments
    for(Attachment a : quoteAttachments) {
        a.ParentId = quotes.get(q.Id).OpportunityId;
    }

}

Attachments are tricky because they have so little metadata. If you need to identify a specific document and your document names are consistent, you could filter on attachment name.

Otherwise, if you need to ensure you're only working with attachments on the quote that came from DocuSign, you may want to build a trigger on the DocuSign envelope status, and work from there.

  • Hi Isaac, I need the attachment to be under the Notes and Attachments related list on the parent (opportunity) from the quote (child). Sorry I didn't see your response before, I didn't see the notification. Thanks for any further help you can provide. – Emma Jan 20 '17 at 15:11
  • Just updated my answer. DocuSign provides a setting for this. If this answer or any other one solved your issue, please mark it as accepted. – Isaac Jan 20 '17 at 16:34
  • Hi Isaac - thanks for the update but unfortunately that just shows how to update the Notes and Attachments on the Object the Envelope was sent from, not how to attach them to a parent object? – Emma Jan 20 '17 at 16:49
  • Sorry, that's right. You've already obtained the attachment from DocuSign that way. See my updated answer. You can write a trigger to move the attachment to the Opportunity. If you need to copy instead of move, reference the following forum post: developer.salesforce.com/forums/?id=906F00000008zRaIAI – Isaac Jan 20 '17 at 17:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.