将 Docusign 信封与 Salesforce 自定义对象相关联

Relate a Docusign Envelope to a Salesforce Custom object

我在 DS 中创建了一个模板,其中包含映射到 Salesforce 字段的自定义标签。当通过 DS 提供的 JS 按钮示例代码使用时,该模板运行良好,字段按预期显示。

我现在正在尝试使用 Docusign SOAPAPI 使流程自动化。创建信封时,不会填充自定义字段;甚至签名者字段。

下面是我的代码:-

DocusignAPI.ArrayOfRecipient1 recipients = new DocusignAPI.ArrayOfRecipient1(); 
    recipients.Recipient = new list<DocusignAPI.Recipient>();
    DocusignAPI.Recipient recipient = new DocusignAPI.Recipient();
    recipient.Email = signer_email;
    recipient.UserName = signer_name;
    recipient.ID = 1;
    recipient.Type_x = 'Signer';
    recipient.RoutingOrder = 1;
    recipients.Recipient.add(recipient);

    DocusignAPI.ArrayOfTemplateReference templateReferences = new DocusignAPI.ArrayOfTemplateReference();
    templateReferences.TemplateReference = new list<DocusignAPI.TemplateReference>();
    DocusignAPI.TemplateReference templateReference = new DocusignAPI.TemplateReference();
    TemplateReference.Template = '6bc2930f-6d46-4804-a9fc-69d1cf3ebe09';
    templateReference.TemplateLocation = 'Server';
    templateReferences.TemplateReference.add(templateReference);


    DocusignAPI.EnvelopeInformation ei = new DocusignAPI.EnvelopeInformation();
    ei.AccountId  = account_id;
    ei.Subject = 'Lorem Ipsum';
    ei.EmailBlurb = 'More text...';
    // Create an envelope and fill it in

    DocusignAPI.CustomField field = new DocusignAPI.CustomField (); 
    field.Name = 'DSFSSourceObjectId'; 
    field.Value = 'a1qW0000000vMCj';
    field.Show = 'false';
    field.CustomFieldType = 'Text';
    DocusignAPI.ArrayOfCustomField arrayOfCustomFields = new DocusignAPI.ArrayOfCustomField();
    arrayOfCustomFields.CustomField  = new list<DocusignAPI.CustomField>();
    arrayOfCustomFields.CustomField.add(field);

     ei.CustomFields = arrayOfCustomFields;

    try {
            DocusignAPI.EnvelopeStatus result = api_sender.CreateEnvelopeFromTemplates(templateReferences, recipients, ei, true);

        envelope_id = result.EnvelopeID;
        System.debug('Returned successfully, envelope_id = ' + envelope_id );
    } catch ( CalloutException e) {
        System.debug('Exception - ' + e );
        error_code = 'Problem: ' + e;
        error_message = error_code;
    }      

所有自定义标签都与我的自定义对象相关,其 id 在上面的 CustomField 中定义。

感谢任何帮助。

原来我需要将对象 API 名称添加到 Id。解决方案是:-

DocusignAPI.CustomField field = new DocusignAPI.CustomField (); 
    field.Name = 'DSFSSourceObjectId'; 
    field.Value = 'a1qW0000000vMCj~Property__c';
    field.Show = 'false';
    field.CustomFieldType = 'Text';