I have the DocuSign API working to pre-fill existing tabs on a template. I am trying to add some additional tabs dynamically for the templaterole signers, but the tabs are not showing up.
Here is my code that I am working with.
string SigningGroupID = "12345";
string RoleName = "Test Signing Group"';
string TemplateId = "XXX-XX-XXXX-XXX";
List<TemplateRole> templateRoles = new List<TemplateRole>();
DocuSign.eSign.Model.Tabs tabs = new DocuSign.eSign.Model.Tabs();
List<Text> TextTabs = new List<Text>();
Text text = new Text();
text.TabLabel = "test_label";
text.XPosition = "100";
text.YPosition = "150";
TextTabs.Add(text);
if (TextTabs.Count > 0) tabs.TextTabs = TextTabs;
TemplateRole doc_signer = new TemplateRole
{
SigningGroupId = SigningGroupID,
RoleName = RoleName,
RoutingOrder = "1",
Tabs = tabs
};
templateRoles.Add(doc_signer);
EnvelopeDefinition envelope = new EnvelopeDefinition();
envelope.EmailSubject = "This is a test";
envelope.Status = "created";
envelope.TemplateId = TemplateId;
envelope.TemplateRoles = templateRoles;
EnvelopesApi envelopeApi = new EnvelopesApi(_apiClient.Configuration);
EnvelopeSummary results = envelopeApi.CreateEnvelope(AccountID, envelope);
Console.WriteLine(results.ToJson());
Do I need some additional items populated on the new Text object (e.g. TabID)? I am not sure why this is not working.
Thanks
jlimited
Correct. You're missing a few properties for your Text object. When you define your Text tab, be sure to connect it to the appropriate recipient, document, and page by specifying the following:
text.documentId
text.pageNumber
text.recipientId
text.xPosition
text.yPosition
text.tabLabel
To determine the three missing values, you can make a request to GET /templates, which will return to you the IDs. SDK method is Templates:get
There are many more properties you can add, but you'll need these to get your tab to display properly.
Related
I have problem with prefilling tabs from prefillTabs group while creating envelope using docusign api. It's impossible to assign values through templateRoles, since these tabs do not have any recipientId. Is it possible somehow to assign values to this kind of tabs?
Yes, you can do that, here is how to do that from the C# SDK:
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, env);
string envelopeId = results.EnvelopeId;
PrefillTabs prefill = new PrefillTabs();
prefill.TextTabs = new List<Text>();
prefill.TextTabs.Add(new Text { PageNumber = "1", DocumentId = "1", Value = "!!!test-inbar!!!" });
Tabs tabs = new Tabs();
tabs.PrefillTabs = prefill;
envelopesApi.CreateDocumentTabs(accountId, envelopeId, "1", tabs);
Or you can use raw JSON API call this way:
Endpoint:
/restapi/v2.1/accounts/[AccountId]/envelopes/[EnvelopeId]/documents/[DocumentId]/tabs
JSON body:
{"prefillTabs":{"textTabs":[{"value":"!!!test-inbar!!!","pageNumber":1,"documentId":"1","xPosition":316,"yPosition":97}]}}
I have the template setup un the sandbox. Whenever I want to be redirected to demo.docusign.net and take action on the PDF, it is auto-populating the tabs. But my requirement is to simply generate the PDF without redirecting to docusign on click of a button. I am sending user information on click of a button to docusign and it has to generate the auto populated customer data on PDF for viewing (draft version). Currently it is generating the template without any dynamic user data, even though I pass the values. Please let me know, if there is any api to perform this.
Thanks in advance
I'm not completely sure I understand what you're trying to do. But sounds like you want:
1. Remote signing. Not Embedded Signing.
2. Populate values of tabs in templates.
You also didn't specify which coding lang you used, so I'm going to give you some C#. You can find the full code examples in all langs in the links above.
// Step 1: Obtain your OAuth token
var accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN}
var accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}
// Step 2: Construct your API headers
var config = new Configuration(new ApiClient(basePath));
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
// Step 3: Create Tabs and CustomFields
// Set the values for the fields in the template
// List item
List colorPicker = new List
{
Value = "green",
DocumentId = "1",
PageNumber = "1",
TabLabel = "list"
};
// Checkboxes
Checkbox ckAuthorization = new Checkbox
{
TabLabel = "ckAuthorization",
Selected = "true"
};
Checkbox ckAgreement = new Checkbox
{
TabLabel = "ckAgreement",
Selected = "true"
};
RadioGroup radioGroup = new RadioGroup
{
GroupName = "radio1",
// You only need to provide the readio entry for the entry you're selecting
Radios = new List<Radio> { new Radio { Value = "white", Selected = "true" } }
};
Text includedOnTemplate = new Text
{
TabLabel = "text",
Value = "Jabberywocky!"
};
// We can also add a new tab (field) to the ones already in the template
Text addedField = new Text
{
DocumentId = "1",
PageNumber = "1",
XPosition = "280",
YPosition = "172",
Font = "helvetica",
FontSize = "size14",
TabLabel = "added text field",
Height = "23",
Width = "84",
Required = "false",
Bold = "true",
Value = signerName,
Locked = "false",
TabId = "name"
};
// Add the tabs model (including the SignHere tab) to the signer.
// The Tabs object wants arrays of the different field/tab types
// Tabs are set per recipient/signer
Tabs tabs = new Tabs
{
CheckboxTabs = new List<Checkbox> { ckAuthorization, ckAgreement },
RadioGroupTabs = new List<RadioGroup> { radioGroup },
TextTabs = new List<Text> { includedOnTemplate, addedField },
ListTabs = new List<List> { colorPicker }
};
// Create a signer recipient to sign the document, identified by name and email
// We're setting the parameters via the object creation
TemplateRole signer = new TemplateRole
{
Email = signerEmail,
Name = signerName,
RoleName = "signer",
Tabs = tabs //Set tab values
};
TemplateRole cc = new TemplateRole
{
Email = ccEmail,
Name = ccName,
RoleName = "cc"
};
// Create an envelope custom field to save our application's
// data about the envelope
TextCustomField customField = new TextCustomField
{
Name = "app metadata item",
Required = "false",
Show = "true", // Yes, include in the CoC
Value = "1234567"
};
CustomFields cf = new CustomFields
{
TextCustomFields = new List<TextCustomField> { customField }
};
// Step 4: Create the envelope definition
EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition
{
// Uses the template ID received from example 08
TemplateId = RequestItemsService.TemplateId,
Status = "Sent",
// Add the TemplateRole objects to utilize a pre-defined
// document and signing/routing order on an envelope.
// Template role names need to match what is available on
// the correlated templateID or else an error will occur
TemplateRoles = new List<TemplateRole> { signer, cc },
CustomFields = cf
};
// Step 5: Call the eSignature REST API
EnvelopesApi envelopesApi = new EnvelopesApi(config);
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeAttributes);
I am using the DocuSign c# SDK and am trying to auto-populate text fields in a DocuSign template with values from an HTML form. I can get the FullName and Email fields to populate as I believe that information is being passed via TemplateRole. However, I can't seem to find an example of how to pass information into a custom field I have created. Everything I can find is pure JSON requests. I assume there has to be methods within the SDK to handle this. Any ideas? Thanks!
public EnvelopeSummary CreateEnvelopeFromTemplate(LoanApplicationModel model)
{
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "DocuSign Test - Please sign this document";
TemplateRole tRole = new TemplateRole();
tRole.Email = model.Email;
tRole.Name = model.FirstName + " " + model.LastName;
tRole.RoleName = "Client";
List<TemplateRole> rolesList = new List<TemplateRole>() {tRole};
envDef.TemplateRoles = rolesList;
envDef.TemplateId = "*******";
envDef.Status = "sent";
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
Trace.WriteLine("Envelope has been sent to " + tRole.Email);
return envelopeSummary;
}
Inside TemplateRole, you need to use Tabs, and if you need to populate for instance TextTab, then you need to add textTab like below to your tRole and the TabLabel of the TextTab should match exactly whats present in your template.
tRole.Tabs = new Tabs();
tRole.Tabs.Text = new List<Text>();
Text text = new Text();
text.TabLabel = "<Template_DataLabel>";
text.Value = "<Value_which_you_want_to_prepoulate>";
tRole.Tabs.Text.Add(text);
We have a requirement where we need to make a couple of PDF forms available using a HTML link to users for signing, but the signer should be a self-signer. In other words, once the signer completes signing using Docusign, they should be able to download the signed documents. However, we as the sender if the HTML link don't want to receive these saved documents as they have Personally Identifiable Information. The signer will upload these documents separately into our application at a later point.
I searched, but couldn't find a way to generate a HTML link for a self-signer. I was able to create a prototype that works for a regular signer, but not for a self-signer.
Any help would be much appreciated. Here's my code right snippet now:
// specify the document we want signed
string SignTest1File = #"C:\Users\skosuri.AA\Desktop\of0306.pdf";
string SignTest2File = #"C:\Users\skosuri.AA\Desktop\epa-credit-release-authorization.pdf";
// Enter recipient (signer) name and email address
string recipientName = "Chris";
string recipientEmail = "xxx.xxx#epa.gov";
// instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
string basePath = "https://demo.docusign.net/restapi";
// instantiate a new api client
ApiClient apiClient = new ApiClient(basePath);
// set client in global config so we don't need to pass it to each API object
Configuration.Default.ApiClient = apiClient;
string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";
Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
// we will retrieve this from the login() results
string accountId = null;
// the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();
// user might be a member of multiple accounts
accountId = loginInfo.LoginAccounts[0].AccountId;
Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());
// Read a file from disk to use as a document
byte[] fileBytes = File.ReadAllBytes(SignTest1File);
byte[] fileBytes2 = File.ReadAllBytes(SignTest2File);
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "Please complete and sign these documents";
// Add a document to the envelope
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = "of0306.pdf";
doc.DocumentId = "1";
doc.TransformPdfFields = "true";
envDef.Documents = new List<Document>();
envDef.Documents.Add(doc);
// Add a second document to the envelope
Document doc2 = new Document();
doc2.DocumentBase64 = System.Convert.ToBase64String(fileBytes2);
doc2.Name = "epa-credit-release-authorization.pdf";
doc2.DocumentId = "2";
doc2.TransformPdfFields = "true";
envDef.Documents.Add(doc2);
// Add a recipient to sign the documeent
Signer signer = new Signer();
signer.Name = recipientName;
signer.Email = recipientEmail;
signer.RecipientId = "1";
signer.DefaultRecipient = "true";
// must set |clientUserId| to embed the recipient
signer.ClientUserId = "1234";
// Create a |SignHere| tab on the document for the recipient to sign
signer.Tabs = new Tabs();
signer.Tabs.SignHereTabs = new List<SignHere>();
signer.Tabs.DateSignedTabs = new List<DateSigned>();
signer.Tabs.FullNameTabs = new List<FullName>();
SignHere signHere = new SignHere();
signHere.AnchorString = "Applicant's Signature:";
signHere.AnchorXOffset = "1.5";
signHere.AnchorYOffset = "0";
signHere.AnchorIgnoreIfNotPresent = "false";
signHere.AnchorUnits = "inches";
signHere.DocumentId = "1";
signHere.RecipientId = "1";
signer.Tabs.SignHereTabs.Add(signHere);
DateSigned ds = new DateSigned();
ds.PageNumber = "3";
ds.XPosition = "380";
ds.YPosition = "550";
ds.DocumentId = "1";
ds.RecipientId = "1";
ds.TabLabel = "Date Signed";
signer.Tabs.DateSignedTabs.Add(ds);
// Create a |SignHere| tab on the second document for the recipient to sign
SignHere signHere2 = new SignHere();
signHere2.PageNumber = "1";
signHere2.XPosition = "80";
signHere2.YPosition = "375";
signHere2.DocumentId = "2";
signHere2.RecipientId = "1";
signer.Tabs.SignHereTabs.Add(signHere2);
FullName fn = new FullName();
fn.PageNumber = "1";
fn.XPosition = "80";
fn.YPosition = "300";
fn.DocumentId = "2";
fn.RecipientId = "1";
signer.Tabs.FullNameTabs.Add(fn);
DateSigned ds2 = new DateSigned();
ds2.PageNumber = "1";
ds2.XPosition = "80";
ds2.YPosition = "475";
ds2.DocumentId = "2";
ds2.RecipientId = "1";
signer.Tabs.DateSignedTabs.Add(ds2);
envDef.Recipients = new Recipients();
envDef.Recipients.Signers = new List<Signer>();
envDef.Recipients.Signers.Add(signer);
// set envelope status to "sent" to immediately send the signature request
envDef.Status = "sent";
// Use the EnvelopesApi to create and send the signature request
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
RecipientViewRequest viewOptions = new RecipientViewRequest()
{
ReturnUrl = "https://www.epa.gov",
ClientUserId = "1234", // must match clientUserId set in step #2!
AuthenticationMethod = "email",
UserName = recipientName,
Email = recipientEmail
};
// create the recipient view (aka signing URL)
ViewUrl recipientView = envelopesApi.CreateRecipientView(accountId, envelopeSummary.EnvelopeId, viewOptions);
// print the JSON response
Console.WriteLine("ViewUrl:\n{0}", JsonConvert.SerializeObject(recipientView));
// Start the embedded signing session!
System.Diagnostics.Process.Start(recipientView.Url);
I don't quite understand your question.
Your app can use a "system user" (an email account such as "noreply#company.com") as the sender and present an embedded signing request to the "self-signer."
That way the "self-signer" can fill in the information and sign.
The signed document will only be visible (via DocuSign) to the system user. You can also set up a purge policy.
But it is not a friendly user experience to ask that the
signer will upload these documents separately into our application at a later point.
Instead, I suggest that you check out the concealValueOnDocument parameter of the text (data) tab.
Docs:
When set to true, the field appears normally while the recipient is adding or modifying the information in the field, but the data is not visible (the characters are hidden by asterisks) to any other signer or the sender.
When an envelope is completed the information is available to the sender through the Form Data link in the DocuSign Console.
This setting applies only to text boxes and does not affect list boxes, radio buttons, or check boxes.
Using this setting enables the signer to see the PII when they sign, but the information is not visible to subsequent signers or viewers of the information.
The PII data is still available via the API so your integration can process it as necessary.
Im using the DocuSign API and im having some issues with the recipient not getting the tabs I save on the website ui. I create a template using DocuSign.com and set the recipient to Role=[testRole] Email=[] Name=[] Type=[Sign] under Recipients and routing. Because I have no recipients yet. Then using the api before i send it out i set the recipient to :
//Recipient Info
Recipient recipient = new Recipient();
recipient.Email = recipientEmail;
recipient.UserName = recipientName;
recipient.SignerName = recipientName;
recipient.Type = RecipientTypeCode.Signer;
recipient.RoleName = recipientRoleName;
recipient.ID = "1";
recipient.SignInEachLocationSpecified = true;
recipient.RoutingOrder = 1;
Recipient[] recipients = new Recipient[] { recipient };
//Template reference from server ID
TemplateReference templateReference = new TemplateReference();
templateReference.Template = templateID;
templateReference.TemplateLocation = TemplateLocationCode.Server;
//Envelope Info
EnvelopeInformation envelopeInfo = new EnvelopeInformation();
envelopeInfo.AccountId = AccountID;
envelopeInfo.Subject = subject;
envelopeInfo.EmailBlurb = message;
I set recipient.RoleName to the same thing as i set on the website UI and still the recipient doesn't get the signature tabs. am i missing something here? Or how do i relate the empty recipient i created using the DocuSign UI to the recipient im sending it to so that it has the tabs present?
Figured it out after shooting in the dark for a while. I was so sure the issue was in Recipient but when I took a look at TemplateReference I found RoleAssignments which apparently setting up in Recipient.Role does nothing. You have to set it up in TemplateReference using something like:
//Recipient Role
var recipientRole = new TemplateReferenceRoleAssignment();
recipientRole.RecipientID = "101";
recipientRole.RoleName = recipientRoleName;
//Template reference from server ID
TemplateReference templateReference = new TemplateReference();
templateReference.Template = templateID;
templateReference.TemplateLocation = TemplateLocationCode.Server;
templateReference.RoleAssignments = new TemplateReferenceRoleAssignment[] { recipientRole };