Reputation: 5845
I am attempting to use the pre-fill tools specifically Text on my Template. I drop a prefill Text box where I want the content to appear and give it a Data Label to use later: "TestValue". The Location values are automatically populated based on where I put the box on the template.
I am using the C# SDK and the following code to set the dynamic value of the Prefill Tabs:
string someValue = "PreFilled Text";
var prefillTabs = new PrefillTabs()
{
TextTabs = new List<Text>()
{
new()
{
PageNumber = "1",
DocumentId = "1",
TabLabel = "TestValue",
Value = someValue
}
}
};
var tabs = new Tabs
{
PrefillTabs = prefillTabs
};
envelopesApi.CreateDocumentTabs(token.Account.AccountId, envelopeId, "1", tabs);
It seems to completely ignore the TabLabel value for the box I added to the Template where I would like the dynamic text to go. It writes the content in the top left corner of the screen:
The only way I could figure out how to move the text was to add hard coded coordinates:
TextTabs = new List<Text>()
{
new()
{
PageNumber = "1",
DocumentId = "1",
TabLabel = "TestValue",
Value = someValue,
XPosition = "317",
YPosition = "204"
}
}
Can someone please explain why it is ignoring the position of the Text box as defined on the template? Is this not possible, or is there an alternative way I can do this? I really don't want to hard code all the positions in the code but just refer to the TabLabel so when it gets moved around I don't have to recompile.
Documentation: https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/tabs/prefilled-tabs/
Upvotes: 0
Views: 264
Reputation: 14050
First, I'm not sure you need to use pre-filled tabs. You can pre-fill regular tabs, which are not pre-fill tabs. This is just a confusion with the name, pre-fill tabs are sender tabs. So, if you have a signer that will see this information, you can use regular tabs for this signer, fill their values from API, and make them read-only if you don't want the signer to be able to edit them.
https://developers.docusign.com/docs/esign-rest-api/how-to/set-template-tab-values/
Shows how to do that.
The issue in your code is that the tabs are in the template, not in the envelope and that since they're pre-filled, it's a little tricky to update their values using the template model. You may need to use composite templates to do that.
I would seriously advise you to not use pre-fill tabs unless there's a reason beyond the fact that you want the tabs to be pre-filled. You can pre-fill a tab that is NOT a pre-fill tab (I know that sounds weird, but that's why I explained it twice).
Upvotes: 0