I am using docusign apex toolkit for creation and signing of my Docusign Envelope Template. I have a text field on the basis of which i am deciding whether the signing of the document should be required or optional. I want to achieve i.e when it is optional if anyone of my recipients opens up the email and sign the document my entire signing process should get completed irrespective of the action from other recipients. But when signing is optional currently it is working as every recipient needs to open email/document and needs to click on finish even if he is not signing the document then only the signing process is getting completed. I am adding few recipients from my contact object and one recipient which is owner of my source record. For owner recipient signing order is 1 and for rest of the recipients signing order is 2. Below is the code for contact recipients creation.
public static List<dfsle.Recipient> populateContactRecipient(List<Contact> contactList,String signingText){
System.debug('signingText inside populateContactRecipient ' +signingText);
Boolean isRequired;
if(signingText == 'Jointly - All Signatures required'){
isRequired=true;
}
else{
isRequired=false;
}
System.debug('isRequired value ' +isRequired);
Integer i=0;
List<dfsle.Recipient> signerRecipientList = new List<dfsle.Recipient>();
for(Contact con : contactList){
i++;
dfsle.Tab hereTab = new dfsle.SignHereTab()
.withScale(0.8) // 1/2 scale
.withRequired(isRequired) // Signing mandatory
.withAnchor(new dfsle.Tab.Anchor(
'x?S' +i, // Anchor string
false, // Allow white space in anchor string
true, // Anchor string is not case sensitive
'', // Horizontal alignment in relation to the anchor text
true, // Ignore if the anchor text is not present in the document
true, // Must match the value of the anchor string in its entirety
'pixels', // Unit of the x and y offset properties
5, // X offset
5 // Y offset
));
dfsle.Recipient myRecipient = new dfsle.Recipient(
null, //Source Id
'Signer',//Type of recipient
i+1, //Sequence
2, //routing order
new dfsle.Recipient.Role('Signer' +i,null), //role -used to match role
//on template if using a template
con.Name, //inPerson Recipient name
con.Email, //inPerson Recipient Email
null, //signing group
null, //phone
null,//no Authentication
null, //note
null, //EmailSettings
null, //host name This is the name of the host for InPerson
null, //host email email of host
false, //sign now
null, //source
false, //read only
false //required
)
.withTabs(new List<dfsle.Tab>{hereTab});
System.debug('myRecipient' +myRecipient);
signerRecipientList.add(myRecipient);
}
/* dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
con.Name, // Recipient name
con.Email, // Recipient email
null, //Optional phone number
'Signer' +i,// Signer role
null) // No Salesforce association --new dfsle.Entity(con.Id));
.withTabs(new List<dfsle.Tab>{hereTab});
System.debug('myRecipient' +myRecipient);
signerRecipientList.add(myRecipient);
System.debug('signerRecipientList' +signerRecipientList);
} */
System.debug('signerRecipientList size ' +signerRecipientList.size());
return signerRecipientList;
}