PHP DocuSign API - Create a non-required field - php

I am using the PHP library provided by DocuSign within my application.
I would like to know how to create a text field that is NOT required to be filled in by the user.
Here's a snippet of what I'm doing.
$text = new \DocuSign\eSign\Model\SignHere();
$text->setAnchorString("Name");
$text->setAnchorXOffset("100");
$text->setAnchorYOffset("-20");
$text->setTabLabel("Name");
$text->setName("Name");
$text_tabs[] = $text;
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setTextTabs($text_tabs);
I want this field to be optional but it's always required when trying to complete the signing process.
Any help would be appreciated!

I believe you just need to set the optional property of the text tab to true.
$text->setOptional("true");
(8/17/16: Updated answer to reference the optional property -- instead of the required property.)

Related

Dynamically adding Signature Tags to a DocuSign custom base64 pdf content through API in php

I want to add DocuSign signature tag dynamically in some specific section of my base64 custom pdf template which created from our web application where user can just click on tag to upload his/her signature not drag and drop his/her signature on specified section.
This is my code sample:
<?php
$pdfurl = 'assets/pdf/test-doc-docusign.pdf';
$docname = basename($pdfurl);
$pdfcontent = file_get_contents($pdfurl);
$base64content = base64_encode($pdfcontent);
$envelopjson = array();
$envelopjson['documents'] = array();
$envelopjson['documents'][0]['documentBase64'] = $base64content;
$envelopjson['documents'][0]['documentId'] = 57577;
$envelopjson['documents'][0]['fileExtension'] = "pdf";
$envelopjson['documents'][0]['name'] = $docname;
$envelopjson['emailSubject'] = "Please Sign";
$envelopjson['recipients'] = array();
$envelopjson['recipients']['signers'] = array();
$envelopjson['recipients']['signers'][0]['name'] = "user full name";
$envelopjson['recipients']['signers'][0]['email'] = "user email";
$envelopjson['recipients']['signers'][0]['recipientId'] = "458585";
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'] = array();
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['xPosition'] = 500;
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['yPosition'] = 500;
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['documentId'] = $trnx_id;
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['pageNumber'] = 1;
$envelopjson['status'] = "sent";
$requestjson = json_encode($envelopjson);
$envelopeinfo = MakeAPICall("POST","v2.1/accounts/".$docusign_account_id."/envelopes",$requestjson,$access_token);
How to solve the issue?
Is your question how to have your application dynamically add DocuSign signing fields (tags) at various places in your documents?
There are several techniques available, especially when you have control over the software that is producing the documents.
For the following techniques, let's say that we ultimately want four tags: a sign here and date signed tag for signers 1 and 2.
Auto Place fields
You can include text in your document that is later used to place fields that use the auto place feature. See the anchorString property.
There are several tricks that may be of help for your use case:
In your source document, you can color the anchor text white (so it won't be visible). This way you can use anchor text such as "signer-1-sign-here" and a tab will be created for every instance of that string. (You do need to program a SignHere tab that looks for your anchorString "signer-1-sign-here".)
You can include anchor text more than once (even in different documents in the same envelope) and the tab will be created at each location.
If you don't include the anchor text, this is not an error. So you can have anchor text such as "signer-1-optional-initials" and if it is in the document an initials tab will be placed, otherwise nothing will happen. (This assumes that you program an initials tab that looks for that anchor string.)
Smart sections
An alternative is to use the smart sections feature and create your document as an HTML document with the tabs included in the HTML.
The templateRoles objects are used to assign recipients to roles of the templates. If the tabs are not coming from the template, you cannot use this object to add tabs.
Instead, you have to make another API call to add the tabs. See code example showing how to update tabs in a template which include PHP code as well.
Alternatively, and the best practice, is to use composite templates, that give you the most flexibility in adding templates, documents, and tabs all in one API call.

How to send variables like {contactfield=id} in MAUTIC email campaign?

I want to send {contactfield=id} (one of the variable of the mautic) into custom headers for a mail that is to be used for a campaign. I am not sure of the right way to send it. I am keeping this variable into custom headers under Channels > Emails and selecting a particular email's advanced settings and into custom headers. This sets the id value of the first contact in the contact list of the segment selected for the campaign into all the remaining contacts. I want to get the dynamic value of each contact's id respectively. How can I get this appropriate result? Thanks in advance.
Last time I checked, not all of the fields in the Email builder can contain tokens. I remember that the Body and Subject allow it, but there were some other fields that did not allow it.
You seem to be getting the correct token, so if it's not returning in the header based on your testing, that field may not get parsed for tokenization on processing.
As pointed out by Jordan Ryan, not all tokens are available under email, however the email object can be tapped by creating a custom plugin.
https://developer.mautic.org/#extending-emails
check out this section, it may help.
The second example on code block shows that you can place your custom placeholder and then replace it programmatically.
/**
* Search and replace tokens with content
*
* #param EmailSendEvent $event
*/
public function onEmailGenerate(EmailSendEvent $event)
{
// Get content
$content = $event->getContent();
// Search and replace tokens
$content = str_replace('{hello}', 'world!', $content);
// Set updated content
$event->setContent($content);
}

Docusign api php add signer on the fly to template

when i add new recepient and sent the document in template using below code
$templateRole = new \DocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("user#email.com");
$templateRole->setName("User Name");
$templateRole->setRoleName("Admin");
I use Docusign Php Client, you can find the whole code below I used for this on that page.
Here it send the email containing document to user#email.com, but user#email.com's user is not able to sign that document.
I've also added the dynamic text to the document in the template.Added one signer recipient to template (because i was not able to add the dynamic labels without it), this user get all the emails even i don't specify him on the above code.
I want something like to send a document in template to different recepients (like user1#gmail.com, user2#gmail.com etc) one at a time (they may or may not have docusign account, though is it possible if they have docusign account?)
I am doing this since 4 days, not finding anything about proceeding furthur, please help.
I have read some of the documentation. As far as I can see you should do the following:
//first signer
$templateRole1 = new \DocuSign\eSign\Model\TemplateRole();
$templateRole1->setEmail("user1#email.com");
$templateRole1->setName("User1 Name");
$templateRole1->setRoleName("Admin");
//second singer
$templateRole2 = new \DocuSign\eSign\Model\TemplateRole();
$templateRole2->setEmail("user2#email.com");
$templateRole2->setName("User2 Name");
$templateRole2->setRoleName("Admin");
And then in the envelop:
$envelop_definition->setTemplateRoles(array($templateRole1, $templateRole2));

PHP: Docusign API autopopulate tabs for template

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

How to add Custom Attributes in Google shopping content api with php?

I am using google shopping Api from last one year it is working properly. But now I want to add new attributes in it such as CustomLabel5. For that I have used setCustomAttributes() method and passed three attributes name, type ,value.
But it is working showing error 400 invalid attribute values. following is my code please check and suggest proper answer for that.
$product = new Google_Service_ShoppingContent_Product();
$data= new Google_Service_ShoppingContent_ProductCustomAttribute();
$data->setName('CustomLabel5');
$data->setType('text');
$data->setValue('test');
$product->setCustomAttributes($data);
Please give answer.
Fairly simple fix here.
setCustomAttributes expects an array of Google_Service_ShoppingContent_ProductCustomAttribute instances.
What you need is:
$attributesArray = array($data);
$product->setCustomAttributes($attributesArray);

Categories