【问题标题】:Updating the data field tag in Docusign from Salesforce data从 Salesforce 数据更新 Docusign 中的数据字段标签
【发布时间】:2014-12-29 22:47:51
【问题描述】:

我正在使用 Docusign API 与 Salesforce 的集成。我需要在文档发送签名后通过调用 Salesforce 的 Docusign API 来更新文档中的数据字段标签。

假设签名者的路由顺序是从签名者 1 到签名者 4。最初,该数据字段标记的值将为空。在签名者 3“完成”他的签名后,我必须触发来自 Salesforce 的 API 调用,并使用从 Salesforce 中对象的自定义字段值中检索到的值更新标签。然后签名者 4 将能够在他签署文档之前看到数据字段标签中的值。

我使用 Merge fields for docusign 将 Salesforce 数据导入该标签。但正如我之前所说,初始值将为空(因为那个合并字段的 salesforce 数据此时也将为空),我必须“停止”签名过程,更新标签,然后继续留下签名者。

有什么方法可以“刷新”信封,以便更新数据字段标签中的值?

docusign 是否允许在发送信封后通过 API 标注使用 Salesforce 数据更新文档中的标签值?

请注意,我已阅读 Docusign RestAPI 指南第 2 版中收件人的修改选项卡(标签)一文。是修改标签类型还是标签值?

【问题讨论】:

  • 没有办法使用开箱即用的 DocuSign for Salesforce 集成来做您想做的事情。您可以通过 API 或 Web 更正文档并更新该值。
  • 谢谢@AndrewWilson。我刚刚做完。将信封张贴到正确状态,放入标签值,将其放入已发送状态。全部通过 RESTapi 完成。
  • 嘿@AndrewWilson,调用Docusign Restapi以“更正”状态发布信封时返回的url需要在浏览器中运行才能激活。只有这样,它才允许我更新标签值。你知道如何将 url 发送到浏览器并在 apex 后台运行吗?
  • 我不太了解 salesforce,但我不知道 APEX 页面如何自动化浏览器工作流程。不是说不可能,我只是不知道该怎么做:)
  • 哦,好的。@AndrewWilson 谢谢。

标签: salesforce apex-code docusignapi apex


【解决方案1】:

使用 Salesforce 和 DS 可以,但不是您现在的方式。我在Send (Load) a URL to web browser and run it in background in APEX的另一个问题上回答了你关于背景正确的问题@

合并字段是问题的一部分,但它们仅在“发送”时显示为值,并且仅在信封成功完成时更新 Salesforce,所以这实际上只是您方案的一半解决方案。

以下是我为另一个 DocuSign 客户所做的示例,作为如何执行此操作的示例,但请联系您的 DocuSign 客户经理,因为我认为如果您正在执行这些类型的高级工作流程,您可以从 DocuSign 的专业中受益我所属的服务组。

1. Components added: 
    DocuSign Connect Object - dseRecipientConnectUpdate
    custom Object - dseRecipientConnectUpdate__c​
    Trigger - dseRCU_AfterUpdate​
    Class - desController (in Sandbox and code below as well)
    Class - CheckRecursive (in sandbox and code below as well)
    DS Template Example -Agreement with ContractID  960BD14E-6A09-4A9E-89E6-77B1D8444B72


2. What you need yet to do
    Replace Send on Behalf user with Sender of envelope via code (hard Coded as david.grigsby@docusign.com in code) lookup using envelopeID in DocuSign Status and get sender, then lookup in user that sender's email
    Classify any stringified body's you want
    Error Condition handling
    Test Classes
    Testing, Testing, testing

How I tested:
    0. Turn on debugging for API user and Myself
    a. Sent Envelope from Template
    b. Signed the first three recipients 
    c. Code updated the dseRecipientConnectUpdate__c​ record (a36) that was the autoresponse blocking user aka just changed record by editing but no real change, then save.

    d. It would then fire trigger again (as mentioned you will need to change the send on behalf of user to automatically for final code to be sending user, but you can make it your email you send envelope by) and it will read recipients, get the contract id recipient and tab, add new recipient and tab with value, delete old reciepents (tag recipient and blocking)

Salesforce 自定义对象:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <!--actionoverrides removed for sake of SO answer size/>
    <compactLayoutAssignment>SYSTEM</compactLayoutAssignment>
    <deploymentStatus>Deployed</deploymentStatus>
    <description>DocuSign Recipient Connect Update</description>
    <enableActivities>true</enableActivities>
    <enableFeeds>false</enableFeeds>
    <enableHistory>true</enableHistory>
    <enableReports>true</enableReports>
    <fields>
        <fullName>RecipStatus__c</fullName>
        <externalId>false</externalId>
        <label>RecipStatus</label>
        <length>50</length>
        <required>false</required>
        <trackHistory>false</trackHistory>
        <trackTrending>false</trackTrending>
        <type>Text</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>RecipientEmail__c</fullName>
        <description>Recipient Email</description>
        <externalId>false</externalId>
        <label>RecipientEmail</label>
        <required>false</required>
        <trackHistory>false</trackHistory>
        <trackTrending>false</trackTrending>
        <type>Email</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>RecipientID__c</fullName>
        <externalId>false</externalId>
        <label>RecipientID</label>
        <length>50</length>
        <required>false</required>
        <trackHistory>false</trackHistory>
        <trackTrending>false</trackTrending>
        <type>Text</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>dsEnvelopeID__c</fullName>
        <description>dsfs__DocuSign_Envelope_ID__c</description>
        <externalId>false</externalId>
        <label>dsEnvelopeID</label>
        <length>56</length>
        <required>false</required>
        <trackHistory>false</trackHistory>
        <trackTrending>false</trackTrending>
        <type>Text</type>
        <unique>false</unique>
    </fields>
    <label>dseRecipientConnectUpdate</label>
    <listViews>
        <fullName>All</fullName>
        <filterScope>Everything</filterScope>
        <label>All</label>
    </listViews>
    <nameField>
        <displayFormat>dseRCU-{0000000000}</displayFormat>
        <label>dseRecipientConnectUpdate Name</label>
        <trackHistory>false</trackHistory>
        <type>AutoNumber</type>
    </nameField>
    <pluralLabel>dseRecipientConnectUpdates</pluralLabel>
    <recordTypeTrackHistory>false</recordTypeTrackHistory>
    <recordTypes>
        <fullName>dseRecipientConnectUpdate</fullName>
        <active>true</active>
        <description>dseRecipientConnectUpdate</description>
        <label>dseRecipientConnectUpdate</label>
    </recordTypes>
    <searchLayouts/>
    <sharingModel>ReadWrite</sharingModel>
</CustomObject>

触发器 ==========

trigger dseRCU_AfterUpdate on dseRecipientConnectUpdate__c (after update) {
    try
    {

        if (CheckRecursive.runOnce())
        {   

            List<dseRecipientConnectUpdate__c> myConnectUpdates = [Select d.dsEnvelopeID__c, d.RecipientID__c, d.RecipientEmail__c, d.RecipStatus__c, d.Id From dseRecipientConnectUpdate__c d WHERE Id IN:Trigger.newMap.keySet()];

            for(dseRecipientConnectUpdate__c myConnectCompleted :myConnectUpdates)
            {
                system.debug(myConnectCompleted.Id);

                if(myConnectCompleted.RecipStatus__c.indexOf('AutoResponded') != -1)
                {
                    system.debug(myConnectCompleted.RecipStatus__c);
                        //Looking for bounce back user via status AutoResponded  and  @accelrys.com emails/recipients
                        if(myConnectCompleted.RecipientEmail__c.indexOf('invalidemail@baddomain.com') != -1)
                        {
                          //do modification to envelope here
                          dseController.updateEnvelope(myConnectCompleted.dsEnvelopeID__c, myConnectCompleted.RecipientID__c);


                        }
                }
            }
        }
    }
    catch(Exception ex)
    {
        system.debug(ex);
    }
    finally
    {

    }  
}

类 ==========

public with sharing class dseController {

    public dseController()
    {

    }

    public dseController(ApexPages.StandardController controller)
    {

    } 

    @future (callout=true)
    public static void updateEnvelope( string envelopeID, string recipientID )
    {
    RecipientResponse RecipientResponseDeserialized = new RecipientResponse();
    RecipientTabResponse RecipientTabResponseDeserialized = new RecipientTabResponse();
    string rResponse = '{}';
    string recipientGuidwithContractTab;
    string recipientGuidForBlockingRecipient;
    string rTabResponse = '{}';
    string rSetRecipientResponse = '{}';
    string rSetTabForRecipientResponse = '{}';
    string rTabRecipientDeleteResponse = '{}';
    string rBlockingRecipientDeleteResponse = '{}';


    try
    {
//Call to get envelope recipients
rResponse = getEnvelopeRecipients(envelopeID);
system.debug(rResponse);

RecipientResponseDeserialized = parseRecipentResponse(rResponse);
system.debug(RecipientResponseDeserialized);

recipientGuidwithContractTab = getRecipientwithContractTab(RecipientResponseDeserialized);
system.debug(recipientGuidwithContractTab);

//Call to get recipient tab
rTabResponse = getRecipientTab(envelopeID, recipientGuidwithContractTab);
system.debug(rTabResponse);

RecipientTabResponseDeserialized = parseRecipientTabResponse(rTabResponse);
system.debug(RecipientTabResponseDeserialized);

//Call to add recipient with new id
rSetRecipientResponse = setRecipientForNewTab(envelopeID,RecipientResponseDeserialized);
system.debug(rSetRecipientResponse);

//Call to add tab to new recipient with new id

rSetTabForRecipientResponse = setNewTabforNewRecipient(envelopeID,RecipientTabResponseDeserialized);
system.debug(rSetTabForRecipientResponse);

//Call to delete old clone recipient
rTabRecipientDeleteResponse = deleteRecipientTab(envelopeID, recipientGuidwithContractTab);
system.debug(rTabRecipientDeleteResponse);

//Call to delete blocking user
recipientGuidForBlockingRecipient = getBlockingRecipient(RecipientResponseDeserialized);
rBlockingRecipientDeleteResponse = deleteBlockingRecipient(envelopeID, recipientGuidForBlockingRecipient);
system.debug(rBlockingRecipientDeleteResponse);
    }
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }    

    }

    public static string getRecipientwithContractTab(RecipientResponse rResponse)
    {
    string rContractTabID = 'Not Found';

    try{

    List<Signer> mySigners = rResponse.signers;
    for(Signer mySigner : mySigners)
    {
    if(mySigner.roleName == 'ContractIDApprover')
    {
    rContractTabID = mySigner.recipientIdGuid;
    }

    }

    }
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        } 

        return rContractTabID;

    }

    public static string getBlockingRecipient(RecipientResponse rResponse)
    {
    string rContractTabID = 'Not Found';

    try{

    List<Signer> mySigners = rResponse.signers;
    for(Signer mySigner : mySigners)
    {
    if(mySigner.roleName == 'BlockingUser')
    {
    rContractTabID = mySigner.recipientIdGuid;
    }

    }

    }
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        } 

        return rContractTabID;

    }


    public static string getEnvelopeRecipients(string envelopeID)
    {
    string response = '{}';
    string DSEndpoint = 'https://demo.docusign.net/restapi/v2/';
    string DSUserId = 'yourdsUserid';
    string DSPassword = 'yourdspassword';
    string DSAccountID = 'yourdsaccountID';
    string DSIntegratorKey = 'yourdsintegratorkey';


    try
{

//FORCES that the DocuSign member has to be in the DocuSign account DSFS is configured for
List<dsfs__DocuSignAccountConfiguration__c> dsAccountConfig = [Select d.dsfs__UseSendOnBehalfOf__c, d.dsfs__DocuSignBaseURL__c, d.dsfs__DSProSFUsername__c, d.dsfs__DSProSFPassword__c, d.dsfs__AccountId__c From dsfs__DocuSignAccountConfiguration__c d limit 1];

for(dsfs__DocuSignAccountConfiguration__c myConfig : dsAccountConfig)
{

DSEndpoint = myConfig.dsfs__DocuSignBaseURL__c + 'restapi/v2/';
DSUserId = myConfig.dsfs__DSProSFUsername__c;
DSPassword = myConfig.dsfs__DSProSFPassword__c;

}

HttpRequest request = new HttpRequest();
request.setEndpoint(DSEndpoint + 'accounts/'+DSAccountID+'/envelopes/'+envelopeID+'/recipients');
request.setMethod('GET');
request.setHeader('Content-Type', 'application/json');
request.setHeader('X-DocuSign-Authentication', '<DocuSignCredentials><Username>'+DSUserId+'</Username><Password>'+DSPassword+'</Password><IntegratorKey>'+DSIntegratorKey+'</IntegratorKey></DocuSignCredentials>');
request.setHeader('Accept', 'application/json');
request.setTimeout(120000);

system.debug(request.getHeader('X-DocuSign-Authentication'));


HttpResponse myResponse = (new Http()).send(request);

system.debug(myResponse.getBody());

if(myResponse.getStatusCode().format()=='200')
{  
response = myResponse.getBody();
system.debug(response);

}

}
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }

        return response;
    }

    public static string getRecipientTab(string envelopeID, string recipientGuid)
    {
    string response = '{}';
    string DSEndpoint = 'https://demo.docusign.net/restapi/v2/';
    string DSUserId = 'yourdsUserid';
    string DSPassword = 'yourdspassword';
    string DSAccountID = 'yourdsaccountID';
    string DSIntegratorKey = 'yourdsintegratorkey';


    try
{

//FORCES that the DocuSign member has to be in the DocuSign account DSFS is configured for
List<dsfs__DocuSignAccountConfiguration__c> dsAccountConfig = [Select d.dsfs__UseSendOnBehalfOf__c, d.dsfs__DocuSignBaseURL__c, d.dsfs__DSProSFUsername__c, d.dsfs__DSProSFPassword__c, d.dsfs__AccountId__c From dsfs__DocuSignAccountConfiguration__c d limit 1];

for(dsfs__DocuSignAccountConfiguration__c myConfig : dsAccountConfig)
{

DSEndpoint = myConfig.dsfs__DocuSignBaseURL__c + 'restapi/v2/';
DSUserId = myConfig.dsfs__DSProSFUsername__c;
DSPassword = myConfig.dsfs__DSProSFPassword__c;

}

HttpRequest request = new HttpRequest();
request.setEndpoint(DSEndpoint + 'accounts/'+DSAccountID+'/envelopes/'+envelopeID+'/recipients/'+recipientGuid+'/tabs/');
request.setMethod('GET');
request.setHeader('Content-Type', 'application/json');
request.setHeader('X-DocuSign-Authentication', '<DocuSignCredentials><Username>'+DSUserId+'</Username><Password>'+DSPassword+'</Password><SendOnBehalfOf>david.grigsby@docusign.com</SendOnBehalfOf><IntegratorKey>'+DSIntegratorKey+'</IntegratorKey></DocuSignCredentials>');
request.setHeader('Accept', 'application/json');
request.setTimeout(120000);

system.debug(request.getHeader('X-DocuSign-Authentication'));


HttpResponse myResponse = (new Http()).send(request);

system.debug(myResponse.getBody());

if(myResponse.getStatusCode().format()=='200')
{  
response = myResponse.getBody();
system.debug(response);

}

}
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }

        return response;
    }

    public static string setRecipientForNewTab(string envelopeID, RecipientResponse rResponse)
    {
    string response = '{}';
    string DSEndpoint = 'https://demo.docusign.net/restapi/v2/';
    string DSUserId = 'yourdsUserid';
    string DSPassword = 'yourdspassword';
    string DSAccountID = 'yourdsaccountID';
    string DSIntegratorKey = 'yourdsintegratorkey';


    try
{

//FORCES that the DocuSign member has to be in the DocuSign account DSFS is configured for
List<dsfs__DocuSignAccountConfiguration__c> dsAccountConfig = [Select d.dsfs__UseSendOnBehalfOf__c, d.dsfs__DocuSignBaseURL__c, d.dsfs__DSProSFUsername__c, d.dsfs__DSProSFPassword__c, d.dsfs__AccountId__c From dsfs__DocuSignAccountConfiguration__c d limit 1];

for(dsfs__DocuSignAccountConfiguration__c myConfig : dsAccountConfig)
{

DSEndpoint = myConfig.dsfs__DocuSignBaseURL__c + 'restapi/v2/';
DSUserId = myConfig.dsfs__DSProSFUsername__c;
DSPassword = myConfig.dsfs__DSProSFPassword__c;

}

Signer mySignerToAdd = new Signer();

List<Signer> mySigners = rResponse.signers;
    for(Signer mySigner : mySigners)
    {
    if(mySigner.roleName == 'ContractIDApprover')
    {
    mySignerToAdd = mySigner;
    }

    }


    String myBody;
    myBody = '{"signers": [{"signInEachLocation": "false","name": "'+mySignerToAdd.name +'Added 1","email": "'+mySignerToAdd.email+'","recipientId": "7","requireIdLookup": "false","routingOrder": "19","roleName": "'+mySignerToAdd.roleName+'1"}]}';

HttpRequest request = new HttpRequest();
request.setEndpoint(DSEndpoint + 'accounts/'+DSAccountID+'/envelopes/'+envelopeID+'/recipients/');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
request.setHeader('X-DocuSign-Authentication', '<DocuSignCredentials><Username>'+DSUserId+'</Username><Password>'+DSPassword+'</Password><SendOnBehalfOf>david.grigsby@docusign.com</SendOnBehalfOf><IntegratorKey>'+DSIntegratorKey+'</IntegratorKey></DocuSignCredentials>');
request.setHeader('Accept', 'application/json');
request.setTimeout(120000);
request.setBody(myBody);

system.debug(request.getHeader('X-DocuSign-Authentication'));


HttpResponse myResponse = (new Http()).send(request);

system.debug(myResponse.getBody());

if(myResponse.getStatusCode().format()=='201')
{  
response = myResponse.getBody();
system.debug(response);

}

}
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }

        return response;
    }

     public static string setNewTabforNewRecipient(string envelopeID, RecipientTabResponse rTabResponse)
    {
    string response = '{}';
    string DSEndpoint = 'https://demo.docusign.net/restapi/v2/';
    string DSUserId = 'yourdsUserid';
    string DSPassword = 'yourdspassword';
    string DSAccountID = 'yourdsaccountID';
    string DSIntegratorKey = 'yourdsintegratorkey';


    try
{

//FORCES that the DocuSign member has to be in the DocuSign account DSFS is configured for
List<dsfs__DocuSignAccountConfiguration__c> dsAccountConfig = [Select d.dsfs__UseSendOnBehalfOf__c, d.dsfs__DocuSignBaseURL__c, d.dsfs__DSProSFUsername__c, d.dsfs__DSProSFPassword__c, d.dsfs__AccountId__c From dsfs__DocuSignAccountConfiguration__c d limit 1];

for(dsfs__DocuSignAccountConfiguration__c myConfig : dsAccountConfig)
{

DSEndpoint = myConfig.dsfs__DocuSignBaseURL__c + 'restapi/v2/';
DSUserId = myConfig.dsfs__DSProSFUsername__c;
DSPassword = myConfig.dsfs__DSProSFPassword__c;

}

TextTabs myTextTabToAdd = new TextTabs();

List<TextTabs> myTextTabs = rTabResponse.textTabs;
    for(TextTabs myTextTab : myTextTabs)
    {
    if(myTextTab.tabLabel == 'ContractID')
    {
    myTextTabToAdd = myTextTab;
    }

    }


    String myBody;
    myBody = '{"textTabs": [{"height": '+myTextTabToAdd.height+',"shared": "'+myTextTabToAdd.shared+'","requireInitialOnSharedChange": "'+myTextTabToAdd.requireInitialOnSharedChange+'","name": "'+myTextTabToAdd.name+'1","value": "ContractID12345","width": '+myTextTabToAdd.width+',"required": "'+myTextTabToAdd.required+'","locked": "'+myTextTabToAdd.locked+'","concealValueOnDocument": "'+myTextTabToAdd.concealValueOnDocument+'","disableAutoSize": "'+myTextTabToAdd.disableAutoSize+'","tabLabel": "'+myTextTabToAdd.tabLabel+'","documentId": "'+myTextTabToAdd.documentId+'","recipientId": "7","pageNumber": "'+myTextTabToAdd.pageNumber+'","xPosition": "'+myTextTabToAdd.xPosition+'","yPosition": "'+myTextTabToAdd.yPosition+'"}]}';

HttpRequest request = new HttpRequest();
request.setEndpoint(DSEndpoint + 'accounts/'+DSAccountID+'/envelopes/'+envelopeID+'/recipients/7/tabs');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
request.setHeader('X-DocuSign-Authentication', '<DocuSignCredentials><Username>'+DSUserId+'</Username><Password>'+DSPassword+'</Password><SendOnBehalfOf>david.grigsby@docusign.com</SendOnBehalfOf><IntegratorKey>'+DSIntegratorKey+'</IntegratorKey></DocuSignCredentials>');
request.setHeader('Accept', 'application/json');
request.setTimeout(120000);
request.setBody(myBody);

system.debug(request.getHeader('X-DocuSign-Authentication'));


HttpResponse myResponse = (new Http()).send(request);

system.debug(myResponse.getBody());

if(myResponse.getStatusCode().format()=='201')
{  
response = myResponse.getBody();
system.debug(response);

}

}
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }

        return response;
    }

    public static string deleteRecipientTab(string envelopeID, string recipientGuid)
    {
    string response = '{}';
    string DSEndpoint = 'https://demo.docusign.net/restapi/v2/';
    string DSUserId = 'yourdsUserid';
    string DSPassword = 'yourdspassword';
    string DSAccountID = 'yourdsaccountID';
    string DSIntegratorKey = 'yourdsintegratorkey';


    try
{

//FORCES that the DocuSign member has to be in the DocuSign account DSFS is configured for
List<dsfs__DocuSignAccountConfiguration__c> dsAccountConfig = [Select d.dsfs__UseSendOnBehalfOf__c, d.dsfs__DocuSignBaseURL__c, d.dsfs__DSProSFUsername__c, d.dsfs__DSProSFPassword__c, d.dsfs__AccountId__c From dsfs__DocuSignAccountConfiguration__c d limit 1];

for(dsfs__DocuSignAccountConfiguration__c myConfig : dsAccountConfig)
{

DSEndpoint = myConfig.dsfs__DocuSignBaseURL__c + 'restapi/v2/';
DSUserId = myConfig.dsfs__DSProSFUsername__c;
DSPassword = myConfig.dsfs__DSProSFPassword__c;

}

HttpRequest request = new HttpRequest();
request.setEndpoint(DSEndpoint + 'accounts/'+DSAccountID+'/envelopes/'+envelopeID+'/recipients/'+recipientGuid);
request.setMethod('DELETE');
request.setHeader('Content-Type', 'application/json');
request.setHeader('X-DocuSign-Authentication', '<DocuSignCredentials><Username>'+DSUserId+'</Username><Password>'+DSPassword+'</Password><SendOnBehalfOf>youremail@yourdomain.com</SendOnBehalfOf><IntegratorKey>'+DSIntegratorKey+'</IntegratorKey></DocuSignCredentials>');
request.setHeader('Accept', 'application/json');
request.setTimeout(120000);

system.debug(request.getHeader('X-DocuSign-Authentication'));


HttpResponse myResponse = (new Http()).send(request);

system.debug(myResponse.getBody());

if(myResponse.getStatusCode().format()=='200')
{  
response = myResponse.getBody();
system.debug(response);

}

}
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }

        return response;
    } 

        public static string deleteBlockingRecipient(string envelopeID, string recipientGuid)
    {
    string response = '{}';
    string DSEndpoint = 'https://demo.docusign.net/restapi/v2/';
    string DSUserId = 'yourdsUserid';
    string DSPassword = 'yourdspassword';
    string DSAccountID = 'yourdsaccountID';
    string DSIntegratorKey = 'yourdsintegratorkey';


    try
{

//FORCES that the DocuSign member has to be in the DocuSign account DSFS is configured for
List<dsfs__DocuSignAccountConfiguration__c> dsAccountConfig = [Select d.dsfs__UseSendOnBehalfOf__c, d.dsfs__DocuSignBaseURL__c, d.dsfs__DSProSFUsername__c, d.dsfs__DSProSFPassword__c, d.dsfs__AccountId__c From dsfs__DocuSignAccountConfiguration__c d limit 1];

for(dsfs__DocuSignAccountConfiguration__c myConfig : dsAccountConfig)
{

DSEndpoint = myConfig.dsfs__DocuSignBaseURL__c + 'restapi/v2/';
DSUserId = myConfig.dsfs__DSProSFUsername__c;
DSPassword = myConfig.dsfs__DSProSFPassword__c;

}

HttpRequest request = new HttpRequest();
request.setEndpoint(DSEndpoint + 'accounts/'+DSAccountID+'/envelopes/'+envelopeID+'/recipients/'+recipientGuid);
request.setMethod('DELETE');
request.setHeader('Content-Type', 'application/json');
request.setHeader('X-DocuSign-Authentication', '<DocuSignCredentials><Username>'+DSUserId+'</Username><Password>'+DSPassword+'</Password><SendOnBehalfOf>youremail@yourdomain.com</SendOnBehalfOf><IntegratorKey>'+DSIntegratorKey+'</IntegratorKey></DocuSignCredentials>');
request.setHeader('Accept', 'application/json');
request.setTimeout(120000);

system.debug(request.getHeader('X-DocuSign-Authentication'));


HttpResponse myResponse = (new Http()).send(request);

system.debug(myResponse.getBody());

if(myResponse.getStatusCode().format()=='200')
{  
response = myResponse.getBody();
system.debug(response);

}

}
catch(Exception ex)
        {
            system.debug(ex);

        }
        finally
        {

        }

        return response;
    }    

public static RecipientResponse parseRecipentResponse(String json) {
return (RecipientResponse) System.JSON.deserialize(json, RecipientResponse.class);
}

public static RecipientTabResponse parseRecipientTabResponse(String json) {
return (RecipientTabResponse) System.JSON.deserialize(json, RecipientTabResponse.class);
}
    public class Signer
    {
    public string name;
    public string email;
    public string recipientId;
    public string recipientIdGuid;
    public string requireIdLookup;
    public string userId;
    public string routingOrder;
    public string roleName;
    public string status;
    public string signedDateTime;
    public string deliveredDateTime;
    public string templateLocked;
    public string templateRequired;

    }

    public class RecipientResponse
    {
    public List<Signer> signers;
    public List<Signer> agents;
    public List<Signer> editors;
    public List<Signer> intermediaries;
    public List<Signer> carbonCopies;
    public List<Signer> certifiedDeliveries;
    public List<Signer> inPersonSigners;
    public String recipientCount;
    public String currentRoutingOrder;


    }

public class TextTabs {
public Integer height;
public String validationPattern;
public String validationMessage;
public String shared;
public String requireInitialOnSharedChange;
public String name;
public String value;
public Integer width;
public String required;
public String locked;
public String concealValueOnDocument;
public String disableAutoSize;
public String tabLabel;
public String documentId;
public String recipientId;
public String pageNumber;
public String xPosition;
public String yPosition;
public String tabId;
}

public class RecipientTabResponse 
{
public List<TextTabs> textTabs;



}



}

【讨论】:

  • 感谢您的回复。我肯定会使用该代码作为参考,但 docusign 不允许我通过运行更正 URL 并通过 REST API GET 请求以“更正”状态发布信封,并且您在其他帖子上回复的 PUT 请求确实如此不允许在发送信封后更新数据字段标签。您能否具体建议我,如何更新信封中的数据字段标签,是否在发送后将信封设置为更正模式?
  • 首先,我们目前没有锁定(Furture),所以当您为收件人“PUT”更改信封(添加、更新、删除)时,您此时处于“正确”状态仅,而通过高级正确的控制台,您将处于该状态,直到完成 UI 和修改,目前也无法通过 UI 获得。因此,发送信封,最后以 99 之类的路由顺序阻止用户,收件人 100 是您具有初始值的用户,然后读取带有值的收件人 100 标签一旦被阻止,在路由顺序 98 和标签处添加相同的收件人,删除收件人100 和 99。
  • 代码中的 cmets 显示了这一点,理解解决此问题的代码非常重要,我再次推荐此类高级工作流程,请联系您的 DocuSign 客户经理参与ProServ 提供此类付费 API 帮助,因此您可以更快地完成项目并获得有效使用 DocuSign API 所需的洞察力。我们现在有一个新的认证和课程,你也可以参加,基于我在 Amazon Kindle 上创建的实验室,价格 blog.grigsbyconsulting.com/?p=281
  • 这很有帮助。谢谢。
  • 太棒了!,然后你会标记为答案吗 :-) 此外,APEX 代码中的 cmets 也应该有助于排序。干杯
猜你喜欢
  • 1970-01-01
  • 2016-05-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-10
相关资源
最近更新 更多