PHP: Docusign API autopopulate tabs for template

2019-07-18 11:59发布

Objective: Autopopulate some values using the tabLabel/value key pair for server templates, using the beta Docusign PHP Client.

I've looked at quite a few stackoverflow posts and unfortunately the one that seems to be the closest related to me seems unanswered: Docusign API - prefilling tab values on envelope created from template

I was unable to find this "SecureField" option in any sort of preferences.

Currently, the name field fills in automatically just because of the template role being set accurately. I didn't have to do this with the tabLabel key, this was done automatically. I have tried creating a company tab, and that fails to autopopulate, so does a random text tab I have tried.

I have currently forked the library and made it PSR-4 compatible, and to achieve this objective I changed the following files:

TemplateRole Model: Modified the constructor to include $tabs, and set $this->tabs if $tabs is set. I added two functions getTabs()/setTabs($tabs) that behave the same as get/set RoleName, Name, Email, etc.

RequestSignatureResource: In the foreach ($templateRoles as $templateRole) I added a 'tabs' key to the array_pusy, and put $templateRole->getTabs().

I created a new TemplateRole('role name', 'person name', 'email', $tabs).

I can see the tabs in the JSON request data. Is there anything I'm missing?

I should also note that I used this post for inspiration, too: How to pre-fill tabs on a server template with the DocuSign API. The issue with this is that if I put textTabs:{text:{tabLabel:"something", value:"some value"}} then I get a response from the API that my request was invalid. I can provide that specific error upon request if needed.

1条回答
混吃等死
2楼-- · 2019-07-18 12:35

The following worked for me :

  $templateRole = new DocuSign\eSign\Model\TemplateRole();
  $templateRole->setClientUserId($email);
  $templateRole->setEmail($email);
  $templateRole->setName($recipientName);
  $templateRole->setRoleName($templateRoleName);

  $textTab = new \DocuSign\eSign\Model\Text();
  // I added this text field manually on docuSign site.
  $textTab->setTabLabel("Field Label");
  $textTab->setValue('Value');

  $tabs = new DocuSign\eSign\Model\Tabs();
  $tabs->setTextTabs(array($textTab));

  $templateRole->setTabs($tabs);
查看更多
登录 后发表回答