We are using DocuSign Apex Toolkit to generate & wned a DocuSign envelope whenever a new record is created and storing the envelope ID on the parent record. We have a lightning component on which we want to display the Envelope as an Iframe. We are using DocuSign "getSigningUrl" & "getEmbeddedSigningUrl" methods. The former one returns "null" & later one is giving error as "The recipient you have identified is not a valid recipient of the specified envelope.". Please suggest.
using embedded method
Url retUrl = new Url('[sfdc base url]');
String envelopeID = 'B33EBEFD-A64F-4D86-9034-6700AFB22EEE';
dfsle.UUID uid = dfsle.UUID.parse(envelopeID);
Url u = dfsle.SigningService.getEmbeddedSigningUrl(uid,retUrl);
System.debug('u---->'+u);
usign signing url method
String envelopeID = 'a271h000000L55d';
dfsle.Envelope e = dfsle.EnvelopeService.getEnvelope(envelopeID);
System.debug('e---->'+e);
Url retUrl = new Url('[sfdc base url]');
Url u = dfsle.SigningService.getSigningUrl(e,retUrl,true );
System.debug('u---->'+u);
You have to ensure:
The envelope is sent. It is not in "draft" state and is not in any other state (like Completed or Void)
The userID for the signer is the correct email/name combination for the recipient for this envelope.
Your envelopeID is valid. In your second code your envelope is not a GUID. EnvelopeID is always a GUID.
Related
I have integrated DocuSign embedded signing into my web app, which is still in development so using DocuSign developer sandbox.
When an envelope is created programmatically, I am including Name, Email and ClientUserId for the signer like this:
var signers = new List<TemplateRole>();
foreach (var r in req.Recipients)
{
var signer = new TemplateRole();
signer.ClientUserId = r.SSOUserId;
signer.Email = r.Email;
signer.Name = r.Name;
signer.RoleName = r.RoleName;
signer.RoutingOrder = r.RoutingOrder.ToString();
signer.Tabs = r.MergeFields
signers.Add(signer);
}
var env = new EnvelopeDefinition()
{
TemplateId = ...,
TemplateRoles = new List<TemplateRole>(signers),
EventNotification = ...,
Status = "Sent"
};
When an embedded recipient view is requested, I include the same exact Name, Email and ClientUserId in the request like this:
var envelopeApi = new EnvelopesApi(ApiClient);
var viewOptions = new RecipientViewRequest
{
ReturnUrl = ...,
AuthenticationMethod = "Password",
ClientUserId = recipient.SSOUserId,
UserName = recipient.Name,
Email = recipient.Email
};
var viewUrl = envelopeApi.CreateRecipientView(AccountId, DocuSignEnvelopeId, viewOptions);
Even though the user may change their Name and/or Email in my app, I have the original values saved in a table and I use those original values when requesting the view from DocuSign. This setup has worked 100% of the time for many months until now when an envelope is having trouble obtaining a recipient view. The envelope was created + viewed last week (April 27, 2022), and when the user tried to sign it today (May 4, 2022), they keep getting this error:
DocuSign.eSign.Client.ApiException: Error calling CreateRecipientView: {
"errorCode":"UNKNOWN_ENVELOPE_RECIPIENT",
"message":"The recipient you have identified is not a valid recipient of the specified envelope."
}
Note that hundreds of envelopes created before and after the above envelope are still able to obtain a recipient view with the exact same code + configuration. The problematic envelope has not expired, I can still see it in the Waiting for Others section of the DocuSign admin site. I have compared its recipient info at DocuSign (by invoking ListRecipients) with the info I have in my database, and the Name, Email, ClientUserId, RoleName, RoutingOrder all match completely. My account is set up to expire envelopes after 120 days, and I am not doing anything during envelope creation to set an expiration date. I have seen many others having this issue but typically their problem is the ClientUserId. My code has that handled, and it works for every other envelope.
The only difference I have seen between this envelope and the others is that ListRecipients results show the affected envelope as having a property
"signatureInfo": {
"fontStyle": "docusign7",
"signatureInitials": "RW",
"signatureName": "Test"
}
that is null for all other envelopes. The documentation states that this property can be set by the sender to pre-fill signature fields. However, I didn't even know about this property before today, so my app has never set it. It would be weird for this property to cause the envelope to be in a state where it cannot be signed anymore but I am struggling to find a reason why this particular envelope cannot be signed. Btw, the signatureName of Test actually matches the Name property of the recipient so its even more confusing why DocuSign is refusing to recognize the signer.
If the envelope is still active, I suggest doing a Recipients:list operation. Also check that the recipient is a "current" recipient. (If there's only one recipient, then this doesn't apply.)
If the Recipients:list doesn't give you any clues then I suggest you contact developer support. They can check our backend logs to see if there's additional information on why the RecipientsView call didn't work.
See page https://support.docusign.com/s/contactSupport?language=en_US First login to that page if you have a production account. You can get support if you only have a developer account.
So I am building a crm/docusign/crm integration. The flow is as follows:
Salesperson clicks a button that takes them to a page on my server(scala play framework instance) that generates and sends the envelope for the document that the user can sign.
Document is sent to user for signing.
Once signed, Write the data back to the crm to each contact/lead/company, depending on field names mapped from docusign to the crm.
This is all working fine and dandy. Problem is, if there are more than 1 contact, they should all get the SAME docusign document and all be signers on it. I am not 100% sure this is even possible, or really why 2 of the same documents is an issue for the client, but it appears to be. The funky part about all of this is I CAN add more than 1 signer at the moment to the same envelope id, but the document is only editable by the first contact on the lead. Everyone else that gets it can't edit it. Once marked finished by the only person that can sign it, it just has their information on it for the other signers and is in read only mode still.
My question is is there any way this is possible? I am assuming that it isn't since each envelope id can really only relate to a single signer. It doesn't even make sense to me how a second signer could sign the same document with the same envelope id and put in different data and it maintain the integrity of both signers since envelope id seems to be a sort of session for the document. If anyone has any experience with the docusign API, I'd really appreciate some insight on this!
Code I'm using:
private def makeEnvelope(contacts: List[Contact], accountInfo: AccountInfo, leadId:Int, whichForm:FORMTYPE) = {
val env = new EnvelopeDefinition
val eventNotification = new EventNotification
eventNotification.setUrl(callbackURL) // fake var name for privacy
env.setTemplateId(templateId)
eventNotification.setRequireAcknowledgment("true")
eventNotification.setIncludeDocuments("true")
eventNotification.setLoggingEnabled("true")
var envelopeEvents : List[EnvelopeEvent]= List.empty[EnvelopeEvent]
val envelopeEvent = new EnvelopeEvent
envelopeEvent.setEnvelopeEventStatusCode("completed")
envelopeEvent.setIncludeDocuments("true")
envelopeEvents = envelopeEvent :: envelopeEvents
eventNotification.setEnvelopeEvents(envelopeEvents.asJava)
env.setEventNotification(eventNotification)
var signerList = List[TemplateRole]()
for(contact <- contacts) {
val signer1 = new TemplateRole
val signEmail = contact.email
signer1.setEmail(signEmail)
signer1.setName(contact.fullName)
signer1.setRoleName("Signatory")
val showAddress: Boolean = contacts.length == 1
// tabs is some data from crm to map to prepopulate docusign when user signs form
val tabs = populateFormData(accountInfo, contact, whichForm, showAddress)
signer1.setTabs(tabs)
signerList = signer1 :: signerList
}
env.setTemplateRoles(signerList.asJava)
env.setStatus("sent")
env
}
If you want a dynamic number of signers for the envelopes (envelope 1 has one signer, envelope 2 has two signers) then do not use a template.
Instead, create the entire envelope object on the fly so it will fit the needs of each envelope. Eg, the envelope object for envelope 2 will include two signer recipients with each having (at least) a sign_here tab.
If you don't know how to create an envelope object that includes two signer recipient objects, ask a new stackOverflow question.
I've setup a developer sandbox environment of DocuSign. Using its C#.NET API Client, I want to send a document for signing to client's more than one personal email ids. Once the client opens any email to see and sign it, the corresponding DocuSign envelope state should get updated to Completed.
Also, I tried to achieve the above behavior through multiple signer recipients, but the envelope state gets marked completed, when all the signer recipients sign the document. Here I want any signer recipient sign should be enough to complete the document signing workflow.
Please suggest how to get it done
Regards,
A
In order to deliver an envelope to several emails in a single role, you'll need to create a Signing Group. Signing Groups can be created and managed through the API, so you'll be able to do that programatically.
While you'll need to implement your own business logic and error checking, a sample of creating a Signing Group in c# looks like:
SigningGroup signingGroup = new SigningGroup();
signingGroup.GroupName = "SigningGroup_" + DateTime.UtcNow.Ticks.ToString();
signingGroup.GroupType = "sharedSigningGroup";
signingGroup.Users = new List<SigningGroupUser>();
SigningGroupUser signingGroupUser1 = new SigningGroupUser();
signingGroupUser1.UserName = "Example Signer";
signingGroupUser1.Email = "signer#example.com";
signingGroup.Users.Add(signingGroupUser1);
SigningGroupUser signingGroupUser2 = new SigningGroupUser();
signingGroupUser2.UserName = "Example Signer";
signingGroupUser2.Email = "personal.email#example.com";
signingGroup.Users.Add(signingGroupUser2);
SigningGroupInformation signingGroupInformation = new SigningGroupInformation();
signingGroupInformation.Groups = new List<SigningGroup> { signingGroup };
SigningGroupsApi signingGroupsApi = new SigningGroupsApi(apiClient.Configuration);
SigningGroupInformation newGroupInfo = signingGroupsApi.CreateList(accountId, signingGroupInformation);
string newGroupId = newGroupInfo.Groups[0].SigningGroupId;
To use the Signing Group in an envelope, define a signer with that group ID:
Signer signer = new Signer
{
SigningGroupId = newGroupId,
RecipientId = "1",
RoutingOrder = "1"
};
Once the envelope is created as a draft, you can then clean up the signing group:
signingGroupsApi.DeleteList(accountId, newGroupInfo);
I have this thing working for like 2 years. Then it stopped sending emails to the signers after they signed a document. By the way the document is created from a widget embedded method.
I'm using the PHP SDK of the docusign API. And here's a summary of my code
$envelopeApi = new \DocuSign\eSign\Api\EnvelopesApi($apiClient);
$document = new \DocuSign\eSign\Model\Document();
$document->setDocumentBase64("My document template");
$document->setName("My template name);
$document->setDocumentId("randomly generated document ID");
// creates the sign here
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setAnchorString("Signature:");
$signHere->setAnchorIgnoreIfNotPresent("false");
$signHere->setAnchorUnits("pixels");
$signHere->setAnchorYOffset("50");
$signHere->setAnchorXOffset("5");
$signHere->setDocumentId("The document ID");
$signHere->setRecipientId("The recipient ID, randomly generated");
// add the signature tab to the envelope's list of tabs
$tabs = new \DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add the signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setName("Recipient Name");
$signer->setEmail("Recipient Email");
$signer->setRecipientId("The recipient ID");
$signer->setTabs($tabs);
$signer->setClientUserId("The client user ID");
// Add a recipient to sign the document
$recipients = new \DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer));
$envelop_definition = new \DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("Mail subject");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelopeApi->createEnvelope("Owner account ID", $envelop_definition, null);
I knew that by adding the envelope definition status "sent" would send a copy to the signer but thats not the case. Did something happened recently on the API that I have to adapt? I checked the documentation but still the same. So I'm not sure if I'm doing the right thing.
Any help would be greatly appreciated. Thanks in advance.
By setting a ClientUserId for your signer, you are creating a Captive Recipient. If you want DocuSign to do email delivery, remove the ClientUserId parameter and a Remote Recipient will be created instead.
i am using the rest api (in php-codeigniter) for docusign. Currently i am creating templates from demo.docusign.net. Is there any API call to create a docusign template from my site by uploading a document ?
Yes,
The VERB is POST and the URI is {vx}/accounts/{accountid}/templates
Documentation Here
The DocuSign REST API Operations is at https://www.docusign.net/restapi/help#
Also the endpoint information is covered in this other Stack Overflow Question What WSDL URL to use for SOAP using Sandbox account?
The DocuSign Online Help Documentation is at https://docs.docusign.com/esign
Here is my solution from this post here. I uploaded an HTML file as a template for the signature document. This will able to give you an idea how to upload files as template.
// set recipient information
$recipientName = "";
$recipientEmail = "";
// configure the document we want signed
$documentFileName = "/../document.html";
$documentName = "document.html";
// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($this->getApiClient());
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents(__DIR__ . $documentFileName)));
$document->setName($documentName);
$document->setFileExtension('html');
$document->setDocumentId("2");
// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setXPosition("100");
$signHere->setYPosition("100");
$signHere->setDocumentId("2");
$signHere->setPageNumber("1");
$signHere->setRecipientId("1");
// add the signature tab to the envelope's list of tabs
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add a signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setEmail($recipientEmail);
$signer->setName($recipientName);
$signer->setRecipientId("1");
$signer->setTabs($tabs);
$signer->setClientUserId("1234"); // must set this to embed the recipient!
// Add a recipient to sign the document
$recipients = new DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer));
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Please sign this doc");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null);
echo "$envelop_summary\n";
If you need more in depth information you can visit the docusign page.
In case it isn't clear, you can also upload a document when creating an envelope via the API. Thus you can bypass creating a template if you don't actually need one.