PHP: Docusign API autopopulate tabs for template

人盡茶涼 提交于 2019-12-23 19:08:12

问题


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:


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);


来源:https://stackoverflow.com/questions/32771518/php-docusign-api-autopopulate-tabs-for-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!