0

I have an account ID and also a template ID, but I am getting null in text custom and list fields. I am using DocuSign's REST api for getting custom fields and listed fields.

 configureApiClient("https://demo.docusign.net/restapi");

 // Step 1: Login()
 // call the Login() API which sets the user's baseUrl and returns their accountId
 AccountId = loginApi(username, password);

 TemplatesApi envelopesApi2 = new TemplatesApi();
 CustomFields cfe = envelopesApi2.ListCustomFields(AccountId, templateId);

Console.WriteLine("Get Custom Fields Information:\n{0}",
                           JsonConvert.SerializeObject(cfe));

Could you please help me to solve my problem?

Thanks in advance

Seyed Parsa Neshaei
  • 3,470
  • 18
  • 30
  • use DocuSign's REST api for this – Hetal Mehta Feb 20 '17 at 06:07
  • What is the value of the templateId you are specifying? – Praveen Reddy Feb 20 '17 at 07:18
  • Have you verified your AccountId & templateId? – M. Adeel Khalid Feb 20 '17 at 08:16
  • template id value is 0beab4c4-8aa9-4b32-9c68-e2d3c2c90f98 and from acoount id i can get other values so account id is verified. and get template list so i can see above templateID so it also right. – Hetal Mehta Feb 20 '17 at 09:19
  • 1
    Can you please share your template creation code. I have verified your templateId in the docusign system, the template Id exists but there are no Custom Fields associated with the template. So the ListCustomFields API is correctly not returning any Custom Fields. – Praveen Reddy Feb 20 '17 at 17:26
  • please see this template id f0fc58fe-0090-4a6f-af4f-fae6a0adecc7 in this template you can see custom text field (txtname). – Hetal Mehta Feb 21 '17 at 02:23
  • @HetalMehta I have looked up your template Id and did not find any Custom Fields associated with the template Id f0fc58fe-0090-4a6f-af4f-fae6a0adecc7 . Can you please look at this answer (http://stackoverflow.com/a/42371195/1219543)and confirm if you are indeed referring to the right term? – Praveen Reddy Feb 22 '17 at 06:03
  • @HetalMehta What is the value of data.CustomFieldsText.Length. Is it greater than Zero? – Praveen Reddy Feb 23 '17 at 23:14

2 Answers2

0

I see that you are adding the custom fields to an envelope and not template. You should use the EnvelopesApi to retrieve the CustomFields. You are incorrectly using the TemplateId.

Use the following code and pass the envelopeId that is returned from the envelopesApi.CreateEnvelope() call

 var envelopesApi2 = new EnvelopesApi();
 CustomFields cfe = envelopesApi2.ListCustomFields(AccountId, envelopeId);
 Console.WriteLine("Get Custom Fields Information:\n{0}",
                   JsonConvert.SerializeObject(cfe));
Praveen Reddy
  • 7,295
  • 2
  • 21
  • 43
-1

Please see my below code to create custom field in templates.

public EnvelopeSummary requestSignatureFromTemplateTest(DocuSignData data)
    {


        // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
        configureApiClient("https://demo.docusign.net/restapi");

        //===========================================================
        // Step 1: Login()
        //===========================================================

        // call the Login() API which sets the user's baseUrl and returns their accountId
        AccountId = loginApi(username, password);

        //===========================================================
        // Step 2: Signature Request from Template 
        //===========================================================

        EnvelopeDefinition envDef = new EnvelopeDefinition();
        envDef.EmailSubject = "Please sign this sample template document11111111111";

        // assign recipient to template role by setting name, email, and role name.  Note that the
        // template role name must match the placeholder role name saved in your account template.  
        TemplateRole tRole = new TemplateRole();
        tRole.Email = recipientEmail;
        tRole.Name = recipientName;
        tRole.RoleName = templateRoleName;

        List<TemplateRole> rolesList = new List<TemplateRole>() { tRole };

        // add the role to the envelope and assign valid templateId from your account
        envDef.TemplateRoles = rolesList;
        envDef.TemplateId = templateId;

        // set envelope status to "sent" to immediately send the signature request
        envDef.Status = "sent";


        List<TextCustomField> customFieldsTextList = new List<TextCustomField>();

        if (data.CustomFieldsText != null)
        {
            //custom text fields
            foreach (DocuSignCustomField customField in data.CustomFieldsText)
            {
                TextCustomField newField = new TextCustomField();
                newField.Name = customField.Name;
                newField.Value = customField.Value;
                newField.Show = customField.Show;
                newField.Required = customField.Required;

                customFieldsTextList.Add(newField);
            }
        }

        CustomFields customFields = new CustomFields();
        customFields.TextCustomFields = customFieldsTextList;


        envDef.CustomFields = customFields;


        // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
        EnvelopesApi envelopesApi = new EnvelopesApi();
        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(AccountId, envDef);

        // print the JSON response
        //Console.WriteLine("Envelope Template Summary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));

        return envelopeSummary;

    } // end requestSignatureFromTemplateTest()

this code for getting custom fields from template

configureApiClient("https://demo.docusign.net/restapi");

// Step 1: Login() // call the Login() API which sets the user's baseUrl and returns their accountId AccountId = loginApi(username, password);

TemplatesApi envelopesApi2 = new TemplatesApi();
CustomFields cfe = envelopesApi2.ListCustomFields(AccountId, templateId);
Console.WriteLine("Get Custom Fields Information:\n{0}",
                       JsonConvert.SerializeObject(cfe));
MarmiK
  • 5,639
  • 6
  • 40
  • 49
  • Welcome to stackOverflow. This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether. – Praveen Reddy Feb 21 '17 at 06:37