0

I am trying to make DocuSign bulk sending work using the C# SDK. I would like to set 2 custom fields for each copy, to later use during the event notification processing of DocuSign Connect.

I am using a template for the bulk operation, which doesn't have these custom fields, but for non-bulk sending, I was able to just add the fields to the envelope definition and it worked just fine.

Here is how I set these fields for bulk and non-bulk sending:

Non-bulk

envelopeDefinition.CustomFields = new CustomFields
{
    TextCustomFields = new List<TextCustomField>
    {
        new TextCustomField
        {
            Name = "CustomField1",
            Value = customField1Value
        },
        new TextCustomField
        {
            Name = "CustomField2",
            Value = customField2Value
        }
    }
};

Bulk - I have done this for every BulkCopy.

CustomFields = new List<BulkSendingCopyCustomField>
{
    new BulkSendingCopyCustomField
    {
        Name = "CustomField1",
        Value = customField1Value
    },
    new BulkSendingCopyCustomField
    {
        Name = "CustomField2",
        Value = customField2Value
    }
}

This results in the following error:

Error calling CreateBulkSendRequest: {
"envelopeOrTemplateId":"c15eddc4-a4ca-495d-8d19-662b0e7194a4",
"batchId":"00000000-0000-0000-0000-000000000000",
"batchSize":"1","totalQueued":"0","queueLimit":"2000","errors":["BULK_SEND_ENVELOPE_CUSTOM_FIELD_DOES_NOT_EXIST_IN_ENVELOPE"],
"errorDetails":["Custom field CustomField1 does not exist in the envelope.","Custom field CustomField2 does not exist in the envelope."]}

Do I need to create these custom fields for this to work on bulk?

UPDATE The process goes like this at the moment: First I create a BulkSendList (containing the setting of custom fields for each BulkCopy inside of it) then pass this BulkSendList to the CreateBulkSendRequest along with the templateId.

var list = _bulkEnvelopesApi.CreateBulkSendList(accountId, bulkSendingList);
BulkSendResponse response = _bulkEnvelopesApi.CreateBulkSendRequest(accountId, list.ListId, new BulkSendRequest()
{
    EnvelopeOrTemplateId = templateId,
});

So I am probably missing the creation of these custom fields then? Though I did not have to create them separately for non bulk envelopes. How do I create them for bulk? I see no such method for bulkEnvelopesApi. I am also using a template not a simple envelope for the list, and the documentation seems to be missing everything when it comes to templates...

Flashcap
  • 141
  • 2
  • 17
  • Are you making a call to set custom fields or to create them? In bulk send you have 2 things, first you create the custom fields so they exist in ALL envelopes, then you set their values, which can be different across envelopes – Inbar Gazit Aug 10 '23 at 17:28
  • I added the part where I create the BulkSendList, and BulkSendRequest. I think I am missing the creation of the custom fields then, but no idea how to do it because apparently there's no such thing in the SDK – Flashcap Aug 11 '23 at 03:47

0 Answers0