• Dhanalakshmi Vellachamy
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
We currently have an approval process and when the Quote as an attachment to the customers when the Quotes is approved.
The APEX trigger is like
trigger approvalQuote on Quote(after update){ set<Id> quoteIdsApproved= new set<Id>(); set<Id> quoteIdsSOWupdates= new set<Id>(); for(Quote q: trigger.new){ quoteIdsSOWupdates.add(q.Id); system.debug('++++++++++++++2'); if(q.Status!=trigger.oldMap.get(q.Id).Status && q.Status=='Approved'){ quoteIdsApproved.add(q.Id); } } if(quoteIdsApproved.size()==1) approvalQuote_Handler.sendEmailAlert(quoteIdsApproved); approvalQuote_Handler.UpdateSOWStage(quoteIdsSOWupdates); }
And in the Handler we have
public class approvalQuote_Handler{ @future public static void sendEmailAlert(set<id> quoteIds){ List<Quote> QuoteLst=[Select Id,Contact.Id,Contact.Email, OwnerId From Quote where id IN :quoteIds]; string emailId=QuoteLst[0].Contact.Email; Id contactId= QuoteLst[0].ContactId; for(Id quoteId: quoteIds){ List<Attachment> attachments = [SELECT Id,Name, Body, ContentType FROM Attachment WHERE ParentId = :quoteId ORDER BY CreatedDate DESC LIMIT 1]; List<Messaging.EmailFileAttachment> email_attachments = new List<Messaging.EmailFileAttachment>(); for(Attachment att : attachments){ Messaging.EmailFileAttachment email_att = new Messaging.EmailFileAttachment(); email_att.setBody(att.Body); email_att.setContentType(att.ContentType); email_att.setFileName(att.Name); email_att.setinline(false); email_attachments.add(email_att); } //generate email here like Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); Id template_id = [SELECT id, name FROM EmailTemplate WHERE developername = 'Quote_Template'].Id; string [] toAddresses=new string[1]; toAddresses[0]=emailId; email.setToAddresses(toAddresses); // Quote contact Email Id //email.setCcAddresses(to_cc_receivers); //list of email addresses email.setTargetObjectId(contactId); //Id of Lead, User or Contact if that is target object. not required email.setWhatId(quoteId); //Id of object that should do field merge email.settemplateid(template_id); email.setFileAttachments(email_attachments); Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); } } }
I am new Docusign and I am not sure how can I embed the Docusign piece in to the sendEmailAlert() so the Attachment allows the users to sign it.
I posted this on Stack Overflow also: http://stackoverflow.com/questions/34804072/auto-add-document-to-docusign-salesforce-using-custom-button

I'm using a DocuSign custom button. I have the document Id of the document I want added into docusign, on my object. Is there a way to automatically add the document using that Id?

The use case is, I'd like my user to hit the send via docusign button, and already have the document and the docusign envelop configured. Currently they have to search for the document, because it's not related to the source record and not in notes and attachments.