2

I am trying to achieve two things here, Assume that I have 3 recipients with me.

  • To notify all the users when a docusign envelope is created.
    • If I am setting the default Recipient.RoutingOrder for all recipients as 1, then all are receiving emails, but the token URL does not have any sign info and also the second two reipients don;t have any merge field values populated in the template.
    • If I am setting the default Recipient.RoutingOrder for all recipients as unique and in a order as 1,2,3, then it is going in sequence order. When the first signer signs then only the 2nd signer recieves the document to sig and then after 2nd signs the 3rd will get. After all sign done only last two signers do get the complete email the first one not getting as I have set the CaptiveInfo and it's ClientUserId value.
Some code snippets are as below :
// TO Form the Recipient info
for(Contact objcontact : lstcontactAll) {
    recipient = new DocuSignAPI.Recipient();
    recipient.ID = signerNumber;
    recipient.Type_x = 'Signer';
    recipient.roleName = 'Signer ' + String.valueOf(signerNumber);
    recipient.RoutingOrder = signerNumber;
    recipient.Email = objcontact.Email; 
    recipient.UserName = objcontact.Name ;           
    recipient.RequireIDLookup = false;
    if(objcontact.RecordType.Name == 'Applicant'){
        applicantIndex = seq;   
        recipient.CaptiveInfo = new DocuSignAPI.RecipientCaptiveInfo(); 
        recipient.CaptiveInfo.ClientUserId = objcontact.Id;
    }
    Recipients.Recipient[seq] = recipient;
    roleAssignment1 = new  DocuSignAPI.TemplateReferenceRoleAssignment();
    roleAssignment1.RoleName = recipient.RoleName;
    roleAssignment1.RecipientID = recipient.ID;
    lstroleAssignment.add(roleAssignment1);
    signerNumber++;
    seq++;
}
// To Create Envelope
DocuSignAPI.EnvelopeStatus es = dsApiSend.CreateEnvelopeFromTemplates(templateReferenceArray, Recipients ,EnvelopeInformation,true);


// Generating URL 
token = dsApiSend.RequestRecipientToken(envelopeId,Recipients.Recipient[applicantIndex].captiveinfo.ClientUserId,Recipients.Recipient[applicantIndex].UserName,Recipients.Recipient[applicantIndex].Email,assertion,clientURLs);    code

I want to send emails to all when the envelope got created and also when the last signer finishes the sign to get the completetion email by all. Is there any way to achieve?

1
  • We are having a challenge with Docusign Embedded Signing. The envelope gets created for the Community user who's signed in and sends out an email to the other signers(applicant, co-applicants, guarantors). The issue is that the Community user for which the envelope is created doesn't receive Signing email(in case user wants to sign in at later time) and Completion email. This is kind of blocker, does anyone have time to help us resolve the issue? – Nruisngh Feb 16 '18 at 15:02
0

Based on the code snippets you've provided, here's what I see happening in your code. You're using this line to assign a list index for Recipient:

applicantIndex = seq;

You only do this if the objcontact.RecordType.Name == 'Applicant'. Afterward, you advance seq using seq++. You're doing the same when you do signerNumber++.

The code where you do that is already nested inside the loop

for(Contact objcontact : lstcontactAll) {

As such, you shouldn't be advancing seq in the outer loop! You should be setting seq to an initial value before entering the outer loop to begin with, then advancing it within the section that contains the if statement.

Since your comment says you want ALL to receive emails, I suspect issue causing that is that you need to build your list of recipients based on signerNumber, not on seq. This would capture all the Signers whether they're Applicants or not.

Editing the structure of your code to look more like this should solve your issue:

signerNumber=1; // this could also be 0 or any value, depending on your needs
seq=1;
for(Contact objcontact : lstcontactAll) {
    recipient = new DocuSignAPI.Recipient();
    recipient.ID = signerNumber;
    recipient.Type_x = 'Signer';
    recipient.roleName = 'Signer ' + String.valueOf(signerNumber);
    recipient.RoutingOrder = signerNumber;
    recipient.Email = objcontact.Email; 
    recipient.UserName = objcontact.Name ;           
    recipient.RequireIDLookup = false;
    if(objcontact.RecordType.Name == 'Applicant'){
        applicantIndex = seq;   
        recipient.CaptiveInfo = new DocuSignAPI.RecipientCaptiveInfo(); 
        recipient.CaptiveInfo.ClientUserId = objcontact.Id;
        seq++;
    }
    Recipients.Recipient[signerNumber] = recipient;
    roleAssignment1 = new  DocuSignAPI.TemplateReferenceRoleAssignment();
    roleAssignment1.RoleName = recipient.RoleName;
    roleAssignment1.RecipientID = recipient.ID;
    lstroleAssignment.add(roleAssignment1);
    signerNumber++;
}

With the above said, base on some of your other comments, it sounds as though it would be best to presort your lstcontactAll to put the contacts in the order you want these delivered. If someone needs to be notified that all have signed, then you may need to add them to the list again with a different role and signerNumber, or something along those lines to ensure they're notified it's time for them to return and see the completed document.

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.