How to get a document's custom fields through DocuSign API? - docusignapi

I am trying to access the custom field values for documents that I download. I am able to list the completed envelopes and download the documents, but the custom fields are showing up as empty?
var docFields = envelopeApi.ListDocumentFields(AccountID, envelopeId, docId);
Console.WriteLine(docFields.DocumentFields.Count);
Count is always zero even though the custom fields have been filled in by the user?

The endpoint which you calling is to download the document custom fields which is added by the sender as the metadata of the document. It will not help you in downloading the form data entered by the signer on the document. To download form data via API, you can use GET /v2/accounts/{accountId}/envelopes/{envelopeId}/form_data, more details available at getFormData DS Docs. You can also use to download tab details for the recipients using GET /v2/accounts/{accountId}/envelopes/{envelopeId}/recipients/{recipientId}/tabs, more details available at Download Recipient tab data
Most recommended way is to setup DS Connect so that you do not have to poll DS API to get envelope status or form data etc, instead host a webservice on your side and configure the same in DocuSign so that DocuSign can push the required data to your webservice in an XML format.

Related

Docusign Powerform

I have powerform within Docusign demo org and I want to create a record in salesforce custom object once the power form is filled by client. I followed this document to map the fields in Docusign connect
https://support.docusign.com/s/articles/How-to-configure-a-PowerForm-to-writeback-to-specific-Salesforce-records?language=en_US&rsc_301
I have mapped Docusign custom field City field to salesforce custom field in settings. Please find mapping in attached image. There is no new record getting created when no match is found and also when it is updating existing record, it is just updating with docusign custom field label to salesforce instead of sending back exact value

Is there a way to get a enveloped document with all custom fields populated on it, using Docusign Rest API?

I am working in a implementation using Docusign to e-sing some documents , I am able to create the envelope successfully a, but when I use the API to get the document in order to show to the user the document before to be signed the document is empty without the custom fields (tabs) that I have set in the template, so my question is : is there any way to get a document with all custom fields populated even is the document had not been signed?
I have tried using the Docusign REST-APIS to get the document:
GET/v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}
That works I am able to get the PDF file but I dont know why the custom fields are not present in the document
If you want to get PDF with the prepopulated tabs data and want to send for review to Sales Officer then you can achieve it by two ways:
If envelope is created with sent status, then you can add Sales
Officer as the first Recipient as Signer Type and add a Approve Tab
for that signer, that way if Sales Officer approves then DocuSign
will move to next recipient in the workflow and if Sales Officer
declines then workflow will stop. So with this approach, everything
is handled by DocuSign and you do not need to get PDF copy and then
get approval via Email by sending PDF as an attachment, also approval
or decline is captured in the audit trail and also in CoC.
If envelope is created with draft status, then you can download the
PDF with prepopulated tab data by using below API call,
https://{{EnvironmentVal}}/restapi/v2/accounts/{{AccountIdVal}}/envelopes/{{envelopeId}}/documents/{{documentId}}?show_changes=true
to make any of the above solution work, you need to need to enable a Sending Setting under Admin at an Account Level which will show the Tab Value on the document for everyone.
There's an account-wide setting for this.
Navigate to Go to Admin > Sending Settings > When an envelope is sent, write the initial value of the field for all recipients.
As far as I know this can't be toggled at the envelope level by the API.

Triggers available in Docusign on document completion

I have a web application integrated with DocuSign API, to pass in recipient details to a DocuSign template and initiate signing process. The template has tags for each recipient to enter relevant information and sign.
Once the document is completed/signed by all recipients, the information available in the document needs to be passed on to another web application bound to a DB. What are the options available in DocuSign to trigger document data(e.g. recipient1 signed date) transferred to a DB/other systems on document completion? Any advice on this is appreciated.
You probably need to provide more specific information but generally, you can use DocuSign Connect and configure your API source to integrate the data. After that, you will be able to use webhooks (or Connect) to send tabs data and signing statuses to your 'other systems'.
Once you get your Connect figured out, you can then have GET request using this
{{baseUrl}}/envelopes/{{envelopeId}}/recipients?include_tabs=true
and then have a wrapper class to export desired tabs (ex. Date Signed or other Text Tabs)
OR you can configure a webhook to sync your data between DocuSign and other systems:
Code Example: Using a Webhook to Track Envelope Status

Save Docusign Document as Template through API

The docusign website allows for me to save a document as a template, but I have not been able to find a way to do this programmatically through the API. Is there a simple way to save a document as a template?
Yes, you can create a Template via the API by issuing this request:
POST /v2/accounts/{accountId}/templates
The API documentation contains details about this operation.
UPDATE
Do I understand correctly that your goal is to create a Template that's based upon an existing DocuSign Document, i.e., to mimic the following functionality in the DocuSign web UI?
If that's the case, then I'm not aware of any single API call that can do this. Instead, I believe you'll need to issue a series of API calls, to retrieve info about the existing Document(s) and then create the new Template using that info:
1) Get information about the existing DocuSign Document (envelope): GET /v2/accounts/{accountId}/envelopes/{envelopeId} (docs)
This operation returns recipient info (including tabs for each recipient) as well as envelope data like email subject, email body, reminders, etc. It also returns a documentsUri property that you can use to get the document(s) that belong to the envelope.
2) Get the list of document(s) that the envelope contains by issuing a GET request to the URI specified by the documentsUri from the prior response. (docs)
This operation returns information about each document in the specified envelope, but does not return document contents.
3) For each document listed in the prior API response, issue a GET request to the URI specified by the uri property for the document. (docs)
4) Finally, create a new Template using the data that you received in response to the previous API requests: POST /v2/accounts/{accountId}/templates (docs)
Note: As a final note -- if you're using one of the DocuSign SDKs, it's possible that there might be a function that you can call to implement this scenario, without having to piece together all of these API calls yourself. I'm not familiar enough with the SDKs to say whether or not they provide this type of functionality, but it'd be worth checking for, if you're using an SDK.

Track envelope status in salesforce using envelope external source Id via API

I am using Docusign package in my org. By using a custom buttom I am able to send a record for docusign approval. In this i set Source Id as record Id and track the status in a custom field on that record. But now I m using Docusign SOAP API and sending a record for docusign via Apex. But now I am unable to set envelope external source id in code and therefore status is not getting updated in that record.
Please reply if anyone has any idea how to set source id via apex and track status?
The best way to do this is to create an envelope custom field in your API call for the recordID and pass that through in your APEX code. The DocuSign for Salesforce manage package does this automatically and that's how the data gets written back to the correct records using Connect.
Create the envelope custom field in DocuSign and then add the CustomField Schema Type to your API call and populate it with the source ID. Then in Connect under the DocuSign Status Object map that Custom Field back to either the five out of the box objects or your custom object.

Resources