docusign / docusign-esign-csharp-client

The Official Docusign C# Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://developers.docusign.com/docs/esign-rest-api/sdks/csharp/
MIT License
129 stars 159 forks source link

Sign here tab is missing when "revisiting" the document #398

Closed esukmonica closed 1 year ago

esukmonica commented 1 year ago

Hi,

I have implemented embedded signing. However, the user might do a "finish later", so I am storing the user signing details at that point as per: https://www.docusign.com/blog/developers/long-lived-embedded-signing-urls

Now, the user is back and I am "recreating" a docusign sign URL to the existing envelope. The problem is that the "Sign HERE" is gone from the document.


        {
            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl = settings.DSReturnUrl,
                ClientUserId = settings.SignerClientUserId,
                AuthenticationMethod = "email",
                UserName = settings.SignerFullName,
                Email =settings.SignerEmail
            };

            var docuSignClient = new DocuSignClient(settings.DsBaseUri);
            docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + settings.DsAccessToken);
            // instantiate an envelopesApi object
            EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(settings.DsAccountId, settings.EnvelopeId, viewOptions);

            return recipientView.Url;
        }

Could you please point me in the right direction? What am I missing? Why is the "Sign Here" gone form the document

Thanks
ByungjaeChung commented 1 year ago

Did you create the signHere tab while you create the envelope? The recipientView API only creates the URL for embedded signing. It does not update or remove the tabs in the envelope that is already created.

esukmonica commented 1 year ago

Hi,

Yes, I did. And the user does get the "Sign Here" tab when the envelope is first created. Please see below the MakeEnvelope method:


public static EnvelopeDefinition MakeEnvelope(DSInfo settings)
        {
            // Data for this method
            // signerEmail
            // signerName
            // signerClientId Including a client user ID automatically specifies the signer as embedded (using your app)
            // Config.docPdf

            byte[] buffer = settings.DocumentToSign; 

            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
            envelopeDefinition.EmailSubject = settings.EmailSubject;
            DocuSign.eSign.Model.Document doc1 = new DocuSign.eSign.Model.Document();

            string doc1b64 = Convert.ToBase64String(buffer);

            doc1.DocumentBase64 = doc1b64;
            doc1.Name = settings.DocumentTitle; // can be different from actual file name
            doc1.FileExtension = settings.DocumentExtension;
            doc1.DocumentId = "1";

            // The order in the docs array determines the order in the envelope
            envelopeDefinition.Documents = new List<DocuSign.eSign.Model.Document> { doc1 };

            // Create a signer recipient to sign the document, identified by name and email
            // We set the clientUserId to enable embedded signing for the recipient
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer
            {
                Email = settings.SignerEmail,
                Name = settings.SignerFullName,
                ClientUserId = settings.SignerClientUserId,
                RecipientId = "1",
            };

            // Create signHere fields (also known as tabs) on the documents,
            // We're using anchor (autoPlace) positioning
            //
            // The DocuSign platform searches throughout your envelope's
            // documents for matching anchor strings.
            SignHere signHere1 = new SignHere
            {
                AnchorString = "/sn1/",
                AnchorUnits = "pixels",
                AnchorXOffset = "10",
                AnchorYOffset = "20",
            };

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List<SignHere> { signHere1 },
            };
            signer1.Tabs = signer1Tabs;

            // Add the recipient to the envelope object
            Recipients recipients = new Recipients
            {
                Signers = new List<Signer> { signer1 },
            };
            envelopeDefinition.Recipients = recipients;

            // Request that the envelope be sent by setting |status| to "sent".
            // To request that the envelope be created as a draft, set to "created"
            envelopeDefinition.Status = "sent";

            return envelopeDefinition;
        }
`
esukmonica commented 1 year ago

I found the problem, when recreating the signing URL, I was passing NULL in the signer client user id

  {
            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl = settings.DSReturnUrl,
                ClientUserId = settings.SignerClientUserId,  <--- THIS WAS NULL
                AuthenticationMethod = "email",
                UserName = settings.SignerFullName,
                Email =settings.SignerEmail
            };

All working now. Thanks!

And one quick question, here is the scenario

  1. User comes in, fills in some data and I generate a docx document, and create the envelope with it.
  2. User is redirected to the signing URL, but decides to sign later
  3. User is back, and maybe realised they have misspelled some of the information, or want to change something else that was used to generate the docx document... , so before I present them with the new signing URL, can I update the document on that existing envelope?

NOTE: there is only one person signing the document

ByungjaeChung commented 1 year ago

Glad to hear that you've solved the issue! Regarding another question, yes, you can update the document in the envelope with the updateDocument API: https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/update/

esukmonica commented 1 year ago

Brilliant, thanks