Reputation: 111
I am using the PHP SDK from https://github.com/docusign/docusign-php-client, and I am attempting to add a Date Signed field to the document. I am successfully creating an envelope, adding a Signer, and sending the Envelope. But I can't figure out what I'm missing with the Date Signed field.
I have searched high and low for an example of adding it, as well as looking at the API docs. I feel like I am missing some method that actually places the field or 'tab' on the document and need a pointer in the right direction. I have found things such as this Question which showed me what properties I needed to set on the DateSigned object, but doesn't help me figure out the PHP methods I need to call.
I'm making a wrapper class for our project, so if you can ignore that bit I will share the code I do have, for adding a Signature Field, then my attempt at adding a Date Signed field for a given Signer. I am confused what I'm missing that will actually place it on the document. I omitted the code where I actually called these methods but the Envelope does send - just no Date Signed field.
Thanks much
function addSigner($signerName, $signerEmail, $xPos, $yPos, $documentId = 1, $documentPage = 1)
{
$index = count($this->signers);
$this->signers[$index] = new DocuSign\eSign\Model\Signer();
$this->signers[$index]->setName($signerName);
$this->signers[$index]->setEmail($signerEmail);
$this->signers[$index]->setRecipientId((string)$index + 1);
$this->sigFields[$index] = new DocuSign\eSign\Model\SignHere();
$this->sigFields[$index]->setXPosition($xPos);
$this->sigFields[$index]->setYPosition($yPos);
$this->sigFields[$index]->setDocumentId($documentId);
$this->sigFields[$index]->setPageNumber($documentPage);
$this->sigFields[$index]->setRecipientId((string)$index + 1);
$this->sigTabs[$index] = new DocuSign\eSign\Model\Tabs();
$this->sigTabs[$index]->setSignHereTabs(array($this->sigFields[$index]));
$this->signers[$index]->setTabs($this->sigTabs[$index]);
return $index; // signerid
}
function addSignerDate($signerId, $xPos, $yPos, $documentId = 1)
{
$index = count($this->dateSignedFields);
$this->dateSignedFields[$index] = new DocuSign\eSign\Model\DateSigned();
// the date should always be on the same page as the signature
$pageNumber = $this->sigFields[$signerId]->getPageNumber();
$this->dateSignedFields[$index]->setPageNumber($pageNumber);
$this->dateSignedFields[$index]->setDocumentId($documentId);
$this->dateSignedFields[$index]->setRecipientId($signerId);
$this->dateSignedFields[$index]->setName('Date Signed');
$this->dateSignedFields[$index]->setTabLabel('Date Signed');
$this->dateSignedFields[$index]->setXPosition($xPos);
$this->dateSignedFields[$index]->setYPosition($yPos);
// EDIT - I added this bit but still no Date Signed. Probably the right track though.
$this->dateSignedTabs[$index] = new DocuSign\eSign\Model\Tabs();
$this->dateSignedTabs[$index]->setDateSignedTabs(array($this->dateSignedFields[$index]));
$this->dateSignedFields[$index]->setTabId($this->dateSignedTabs[$index]);
return $index;
}
Upvotes: 0
Views: 828
Reputation: 111
OK, here's how I fixed it. I changed to only having one Tabs array - no separate one for the Date Signed fields. The Tabs object holds different types of Tabs, so we use the same one for both fields.
function addSigner($signerName, $signerEmail, $xPos, $yPos, $documentId = 1, $documentPage = 1)
{
$index = count($this->signers);
$this->signers[$index] = new DocuSign\eSign\Model\Signer();
$this->signers[$index]->setName($signerName);
$this->signers[$index]->setEmail($signerEmail);
$this->signers[$index]->setRecipientId((string)$index + 1);
$this->sigFields[$index] = new DocuSign\eSign\Model\SignHere();
$this->sigFields[$index]->setXPosition($xPos);
$this->sigFields[$index]->setYPosition($yPos);
$this->sigFields[$index]->setDocumentId($documentId);
$this->sigFields[$index]->setPageNumber($documentPage);
$this->sigFields[$index]->setRecipientId((string)$index + 1);
$this->sigTabs[$index] = new DocuSign\eSign\Model\Tabs();
$this->sigTabs[$index]->setSignHereTabs(array($this->sigFields[$index]));
return $index;
}
function addSignerDate($signerId, $xPos, $yPos, $documentId = 1)
{
$index = count($this->dateSignedFields);
$this->dateSignedFields[$index] = new DocuSign\eSign\Model\DateSigned();
// the date should always be on the same page as the signature
$pageNumber = $this->sigFields[$signerId]->getPageNumber();
$this->dateSignedFields[$index]->setPageNumber($pageNumber);
$this->dateSignedFields[$index]->setDocumentId($documentId);
$this->dateSignedFields[$index]->setRecipientId($signerId);
$this->dateSignedFields[$index]->setName('Date Signed');
$this->dateSignedFields[$index]->setTabLabel('Date Signed');
$this->dateSignedFields[$index]->setXPosition($xPos);
$this->dateSignedFields[$index]->setYPosition($yPos);
$this->sigTabs[$signerId]->setDateSignedTabs(array($this->dateSignedFields[$index]));
return $index;
}
Then I add them to the document later in my SendEnvelope method:
foreach($this->signers as $signerId => $signer)
{
$this->signers[$signerId]->setTabs($this->sigTabs[$signerId]);
}
Upvotes: 2