Skip to main content
Solved

Create envelope with Text Tabs populated via API, in Node.js

  • September 9, 2024
  • 4 replies
  • 177 views

Forum|alt.badge.img+2

Hi everyone,

I’m able to send out envelopes for signature in Node.js via the docusign-esign NPM package, but my text fields are not populating for some reason.  I am referencing the documentation linked here.  I’ve tried both on our developer account as well as our production account.

Here is my code for creating the envelope.  I am getting the label and ID for the text fields through the Docusign API, and I have double-checked the label is correct through the Docusign webapp itself.


function makeEnvelope(args) {
try {
let envelope = new docusign.EnvelopeDefinition();
envelope.templateId = args.templateId;

let text = docusign.Text.constructFromObject({
tabLabel: TAB_1_LABEL,
value: 'test text field!',
});

let textExtra = docusign.Text.constructFromObject({
font: 'helvetica',
font_size: 'size14',
tabLabel: TAB_2_LABEL,
height: '23',
width: '84',
required: 'false',
bold: 'true',
value: "test value!!!!",
locked: false,
tabId: TAB_2_ID
});

let tabsFromDocs = docusign.Tabs.constructFromObject({
textTabs: [text, textExtra]
});

let signer1 = docusign.TemplateRole.constructFromObject({
email: args.signerEmail,
name: args.signerName,
roleName: 'signer',
tabs: tabsFromDocs
});

let signer2 = new docusign.TemplateRole();
signer2.email = args.signer2Email;
signer2.name = args.signer2Name;
signer2.roleName = 'signer';

envelope.templateRoles = [signer1, signer2];
envelope.status = 'sent';

return envelope;
} catch (error) {
console.log({ errorMakeEnvelope: error });
}
}

Thank you in advance!

Best answer by Renan.Araujo

Hey @Olivia_Developer

Based in your examples I’m seeing that both roleName entries are defined with the same value (signer).

This is not a static value provided by Docusign, this value is based on what you defined in your template when creating it at Docusign webpage. 

Please check and make sure that the roles provided in your API call are the same as declared in your template (and keep in mind these are case sensitive, so in case you set in your template the role to be “Signer” and you declare in your API call as “signer” it won’t work). 

😉

4 replies

JohnSantos
Guru
Forum|alt.badge.img+19
  • Guru
  • 1076 replies
  • September 9, 2024

@Olivia_Developer 

Looking at your code, you seem to be on the right track in constructing the envelope and setting up the text fields. However, if the text fields are not populating as expected, here are some potential troubleshooting steps and recommendations to ensure the fields are correctly populated:

let textExtra = docusign.Text.constructFromObject({
    font: 'helvetica',
    fontSize: 'Size14',  // Corrected size format
    tabLabel: TAB_2_LABEL,
    height: 23,          // Ensure this is a number
    width: 84,           // Ensure this is a number
    required: false,     // Boolean rather than string
    bold: true,          // Boolean rather than string
    value: "test value!!!!",
    locked: false,
    tabId: TAB_2_ID
});
 


Forum|alt.badge.img+2
  • Author
  • New Voice
  • 2 replies
  • September 9, 2024

Hi John, thanks for taking the time to look into this!  I made those changes but unfortunately I’m still not seeing either text field get populated.


Renan.Araujo
Docusign Employee
Forum|alt.badge.img+3
  • 16 replies
  • Answer
  • September 10, 2024

Hey @Olivia_Developer

Based in your examples I’m seeing that both roleName entries are defined with the same value (signer).

This is not a static value provided by Docusign, this value is based on what you defined in your template when creating it at Docusign webpage. 

Please check and make sure that the roles provided in your API call are the same as declared in your template (and keep in mind these are case sensitive, so in case you set in your template the role to be “Signer” and you declare in your API call as “signer” it won’t work). 

😉


Forum|alt.badge.img+2
  • Author
  • New Voice
  • 2 replies
  • September 11, 2024

Thank you so much!!  It is working now.