I am generating the envelope and document via the DocuSign Salesforce API, and the recipient's first and last name apparently can only be set when it's concatenated. Is there a way to add a space between the first and last name? You'll see in the code below where I try adding a space, and when I do, I get the following exception:
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: The recipient you have identified is not a valid recipient of the specified envelope. faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx`
Code:
// Recipient
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = 1;
recipient.Type_x = Constants.const_Signer;
recipient.RoutingOrder = 1;
recipient.Email = cnt.EmailAddress1__c;
recipient.RoleName = Constants.const_RoleCustomer;
recipient.UserName = cnt.FirstName__c + cnt.LastName__c; //tried adding a space here...
recipient.RequireIDLookup = false;
recipient.captiveInfo = new DocuSignAPI.RecipientCaptiveInfo();
recipient.captiveInfo.ClientUserId = clientUserID;
DocuSignAPI.ArrayOfRecipient1 Recipients = new DocuSignAPI.ArrayOfRecipient1();
Recipients.Recipient = new DocuSignAPI.Recipient[1];
Recipients.Recipient[0] = recipient;
envelope.Recipients = new DocuSignAPI.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1];
envelope.Recipients.Recipient[0] = recipient;
envelope.AccountId = objConstantSetting.Docusign_Account_ID__c;
envelope.Autonavigation = true;
// Envelope needs Documents, Recipients, Tabs and a Subject.
envelope.Tabs = new DocuSignAPI.ArrayOfTab();
envelope.Tabs.Tab = new List<DocuSignAPI.Tab>();
DocuSignAPI.Tab t = new DocuSignAPI.Tab();
t.Name = 'Name';
t.Type_x = 'FullName';
DocuSignAPI.AnchorTab at = new DocuSignAPI.AnchorTab();
at.AnchorTabString = dsTag.AnchorTabString__c;
t.RecipientID = recipient.ID;
t.CustomTabRequired = true;
at.IgnoreIfNotPresent = true;
t.AnchorTabItem = at;
envelope.Tabs.Tab.add(t);
envelope.Subject = Label.Docusign_Email_Subject; // + account.AccountNumber;
Above error normally comes when you are trying to generate the RequestRecipientToken
for embedded signers, and the recipient's details which you are passing in RequestRecipientToken
API call is not the same which are present in the envelope.
Below is the SOAP API call, to create Envelope with FullName tab and recipient name has space in it and its coming fine on the document. Try testing the flow using SOAPUI.
Create Envelope call:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.docusign.net/API/3.0">
<soapenv:Header/>
<soapenv:Body>
<ns:CreateAndSendEnvelope>
<ns:Envelope>
<ns:AccountId>e6043e37-08a9-4892-9e12-75b4d8bfef2a</ns:AccountId>
<ns:Documents>
<ns:Document>
<ns:ID>32093411</ns:ID>
<ns:Name>Document Name</ns:Name>
<ns:PDFBytes>PDFBytes</ns:PDFBytes>
<ns:FileExtension>pdf</ns:FileExtension>
</ns:Document>
</ns:Documents>
<ns:Recipients>
<ns:Recipient>
<ns:ID>45399085</ns:ID>
<ns:UserName>FirstName LastName</ns:UserName>
<ns:Email>email@gmail.com</ns:Email>
<ns:Type>Signer</ns:Type>
<ns:RoutingOrder>1</ns:RoutingOrder>
<ns:CaptiveInfo>
<ns:ClientUserId>1234</ns:ClientUserId>
</ns:CaptiveInfo>
</ns:Recipient>
</ns:Recipients>
<ns:Tabs>
<ns:Tab>
<ns:DocumentID>32093411</ns:DocumentID>
<ns:RecipientID>45399085</ns:RecipientID>
<ns:PageNumber>1</ns:PageNumber>
<ns:XPosition>71</ns:XPosition>
<ns:YPosition>500</ns:YPosition>
<ns:ScaleValue>1</ns:ScaleValue>
<ns:Type>FullName</ns:Type>
<ns:Name>FullName</ns:Name>
<ns:TabLabel>Name d39c7430-7321-4c97-a1b9-5d980fda7883</ns:TabLabel>
<ns:CustomTabRequired>false</ns:CustomTabRequired>
<ns:CustomTabLocked>false</ns:CustomTabLocked>
<ns:TemplateLocked>false</ns:TemplateLocked>
<ns:TemplateRequired>false</ns:TemplateRequired>
<ns:Font>LucidaConsole</ns:Font>
<ns:FontColor>Black</ns:FontColor>
<ns:FontSize>Size9</ns:FontSize>
</ns:Tab>
</ns:Tabs>
<ns:Subject>Email Subject</ns:Subject>
<ns:EmailBlurb>Email Blurb</ns:EmailBlurb>
</ns:Envelope>
</ns:CreateAndSendEnvelope>
</soapenv:Body>
</soapenv:Envelope>
RequestRecipientToken:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.docusign.net/API/3.0">
<soapenv:Header/>
<soapenv:Body>
<ns:RequestRecipientToken>
<ns:EnvelopeID>ece0d433-52a7-4e0c-a502-c57ff205df3c</ns:EnvelopeID>
<ns:ClientUserID>1234</ns:ClientUserID>
<ns:Username>FirstName LastName</ns:Username>
<ns:Email>email@gmail.com</ns:Email>
<ns:AuthenticationAssertion>
<ns:AuthenticationInstant>2017-08-09T01:25:33Z</ns:AuthenticationInstant>
<ns:AssertionID>1234</ns:AssertionID>
<ns:AuthenticationMethod>Password</ns:AuthenticationMethod>
<ns:SecurityDomain>www.google.com</ns:SecurityDomain>
</ns:AuthenticationAssertion>
<ns:ClientURLs>
<ns:OnSigningComplete><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnSigningComplete>
<ns:OnViewingComplete><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnViewingComplete>
<ns:OnCancel><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnCancel>
<ns:OnDecline><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnDecline>
<ns:OnSessionTimeout><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnSessionTimeout>
<ns:OnTTLExpired><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnTTLExpired>
<ns:OnException><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnException>
<ns:OnAccessCodeFailed><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnAccessCodeFailed>
<ns:OnIdCheckFailed><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnIdCheckFailed>
<ns:OnFaxPending><![CDATA[http://www.google.com?envId=[[envelopeId]]&recipientEmail=[[recipientEmail]]]]></ns:OnFaxPending>
</ns:ClientURLs>
</ns:RequestRecipientToken>
</soapenv:Body>
</soapenv:Envelope>