I'm experimenting with the DocuSign REST SDK (nuget package) and am having trouble getting custom fields returned with the Envelope metadata. I've tried creating an Envelope using a composite template with custom fields as part of both the Inline Template and the Envelope Definition just to see what I can get back:
CompositeTemplate composite = new CompositeTemplate();
composite.Document = document;
InlineTemplate inlineTemplate = new InlineTemplate();
inlineTemplate.Sequence = "1";
inlineTemplate.Recipients = new Recipients();
inlineTemplate.Recipients.Signers = new List<Signer>();
inlineTemplate.Recipients.Signers.Add(signer);
inlineTemplate.CustomFields = new CustomFields(null, new List<TextCustomField>());
TextCustomField iCF = new TextCustomField();
iCF.Name = "InlineTemplateCustomField";
iCF.Value = "202303";
inlineTemplate.CustomFields.TextCustomFields.Add(iCF);
ServerTemplate serverTemplate = new ServerTemplate("2", "8e556cd1-d343-4c07-9401-d88b00a67671"); //payment template id
composite.InlineTemplates = new List<InlineTemplate>();
composite.InlineTemplates.Add(inlineTemplate);
composite.ServerTemplates = new List<ServerTemplate>();
composite.ServerTemplates.Add(serverTemplate);
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.CompositeTemplates = new List<CompositeTemplate>();
envDef.CompositeTemplates.Add(composite);
TextCustomField cf = new TextCustomField();
cf.Name ="EnvelopeCustomField";
cf.Value = "101202";
envDef.CustomFields = new CustomFields(null, new List<TextCustomField>());
envDef.CustomFields.TextCustomFields.Add(cf);
ApiClient apiClient = new ApiClient(basePath);
apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envDef);
I can retrieve the InlineTemplateCustomField using the ListCustomFields method but if I retrieve the Envelope results with the "custom_fields" option the Envelope's custom fields array will be null. Is this expected?
CustomFieldsEnvelope customFieldsEnvelope = envelopesApi.ListCustomFields(accountId, "743e9d25-e093-43ec-acbd-5fbfce053e92");
EnvelopesApi.GetEnvelopeOptions options = new EnvelopesApi.GetEnvelopeOptions();
options.include = "custom_fields";
Envelope results = envelopesApi.GetEnvelope(accountId, "743e9d25-e093-43ec-acbd-5fbfce053e92", options);
I would prefer to get the Envelope's status and custom fields in one API call if possible, which is why I was hoping to get the "EnvelopeCustomField" back in the GetEnvelope call.