Issue
I have created a template on the DocuSign management console with some read-only Custom Fields. When I create an envelope using this template via the eSignature REST API, I want these Custom Fields to be populated with personalized data (e.g. name, address, loan#) for each signing. This would be like doing a mail merge on a MS Word document to personalize it and then using the merged document for the signing.
Following the example at https://developers.docusign.com/docs/esign-rest-api/how-to/set-envelope-tab-values, I include all the data for the Custom Fields in my envelope creation API request as text tabs. The tabLabel property of the text tabs in my code matches the Data Label property of the Custom Field in the template on the DocuSign console. The main difference between the example and my code is that the example includes the document and specifies the placement of the tabs within that document whereas my code is referencing a template with Custom Fields (text tabs) that already exist on the console so doesn't include the document or the placement of the tabs in the request.
If I specify that I want a remote ceremony (signer gets an email with a link, the links takes them to DocuSign for the signing), the document being signed has the Custom Fields populated correctly with my data. If I specify that I want an embedded ceremony (signer clicks a link on my website, I request an embedded client view from DocuSign and then direct the signer to that client view), the document being signed does not have the Custom Fields at all. It doesn't even show the default placeholder values of the Custom Field. Can anybody help me figure out what I am doing wrong? Is it possible to populate Custom Fields in an embedded ceremony like I am trying to do? Why would they work in a remote ceremony but not embedded ceremony?
My code to build the envelope is as follows:
private static EnvelopeDefinition CreateEnvelopeFromTemplate(MyAppSettings appSettings, MyRequest req)
{
var eventNotification = new EventNotification()
{
EnvelopeEvents = new List<EnvelopeEvent>()
{
new EnvelopeEvent() { EnvelopeEventStatusCode = "Sent" },
new EnvelopeEvent() { EnvelopeEventStatusCode = "Delivered" },
new EnvelopeEvent() { EnvelopeEventStatusCode = "Declined" },
new EnvelopeEvent() { EnvelopeEventStatusCode = "Voided" },
new EnvelopeEvent() { EnvelopeEventStatusCode = "Completed" }
},
IncludeCertificateOfCompletion = "true",
IncludeDocuments = "true",
IncludeEnvelopeVoidReason = "true",
IncludeHMAC = "true",
IncludeTimeZone = "true",
LoggingEnabled = "true",
RecipientEvents = new List<RecipientEvent>()
{
new RecipientEvent() { RecipientEventStatusCode = "Sent" },
new RecipientEvent() { RecipientEventStatusCode = "Delivered" },
new RecipientEvent() { RecipientEventStatusCode = "Declined" },
new RecipientEvent() { RecipientEventStatusCode = "Completed" }
},
RequireAcknowledgment = "true",
Url = appSettings.Connect.WebhookUrl
};
var textTabs = new List<Text>();
if (req.DocuSignTemplateData != null && req.DocuSignTemplateData.Count > 0)
{
foreach (KeyValuePair<string, string> field in req.DocuSignTemplateData)
{
textTabs.Add(new Text(TabLabel: field.Key, Value: field.Value));
}
}
var signers = new List<TemplateRole>();
foreach (var r in req.Recipients)
{
var signer = new TemplateRole();
if (req.CeremonyType == EMBEDDED_SIGNING)
{
signer.EmbeddedRecipientStartURL = $"{appSettings.EmbeddedSigningUrl}{req.CeremonyParams}";
signer.ClientUserId = r.SSOUserId;
}
signer.Email = r.Email;
signer.Name = r.Name;
signer.RoleName = r.RoleName;
signer.RoutingOrder = r.RoutingOrder.ToString();
if (textTabs.Count > 0)
{
signer.Tabs = new Tabs
{
TextTabs = textTabs
};
}
signers.Add(signer);
}
var env = new EnvelopeDefinition()
{
TemplateId = req.DocuSignTemplateId.ToString(),
TemplateRoles = new List<TemplateRole>(signers),
EventNotification = eventNotification,
Status = "Sent"
};
return env;
}
Solution
To help with the debugging, I would use API logging to see exactly what your app is sending to DocuSign.
You can set tab values with embedded signing with a template. But I'm not sure that you can use a role
object to do so. Instead, use the composite templates pattern.
Here's a working example of using a template and:
- Setting a signer role to use embedded signing
- Setting a tab value.
Note that you can use the Change language
button in the API Request Builder app to have it generate C# code for you.
You may find my blog post on using templates useful too.
Answered By - Larry K Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.