2017-12-16 3 views
0

DocuSign에서 값을 Salesforce로 다시 전달하지 않습니다. 그리고 Even는 로그에 오류를주지 않습니다.DocuSign에서 Salesforce에 값을 전달하지 않습니다.

원본 ID 및 MergeFieldXml 탭 옵션과 같은 사용자 정의 필드를 write-back = true와 함께 사용했습니다. 그러나 그것은 효과가 없습니다.

무엇이 잘못 되었습니까?

DocuSign 계정의 병합 필드가 활성화되어 있습니다.

내 코드 예제 :

global class AnnualContract 
{  
    webService static string AM_SendToDocuSign(String id, string strObjType) 
    { 
    Docusign_API_Setting__c APISetting = Docusign_API_Setting__c.getInstance('API Settings'); 
    String envelopeId = ''; 
    string DealerName = ''; 
    string DealerId = ''; 
    String accountId = APISetting.AccountId__c; 
    String userId = APISetting.UserId__c; 
    String password = APISetting.Password__c; 
    String integratorsKey = APISetting.IntegratorsKey__c; 
    String webServiceUrl = APISetting.WebServiceUrl__c; 

    list<Lead> lstLead = new list<Lead>(); 
    list<Contact> lstContact = new list<Contact>(); 

    if(strObjType == 'Lead') 
     { 
      lstLead = [SELECT Name,Status,Email,FirstName,LastName,Owner.Name,Title,FROM Lead where id = : Id limit 1]; 
     } 

    StaticResource objSR = [SELECT Id,name, SystemModStamp FROM StaticResource WHERE Name = 'AnnualContractPDF' LIMIT 1]; 

     String url_file_ref = '/resource/' + String.valueOf(((DateTime)objSR.get('SystemModStamp')).getTime())+ '/' + objSR.get('Name'); 
     if(strObjType == 'Lead') 
     { 
      DealerName = lstLead[0].Name; 
     } 

    DocuSignAPI.APIServiceSoap dsApiSend = new DocuSignAPI.APIServiceSoap(); 
    dsApiSend.endpoint_x = webServiceUrl; 

    //Set Authentication 
    String auth = '<DocuSignCredentials><Username>'+ userId 
     +'</Username><Password>' + password 
     + '</Password><IntegratorKey>' + integratorsKey 
     + '</IntegratorKey></DocuSignCredentials>'; 
    System.debug('Setting authentication to: ' + auth); 

    dsApiSend.inputHttpHeaders_x = new Map<String, String>(); 
    dsApiSend.inputHttpHeaders_x.put('X-DocuSign-Authentication', 
            auth); 

    DocuSignAPI.Envelope envelope = new DocuSignAPI.Envelope(); 
    envelope.Subject = 'Please Sign this Contract' + lstLead[0].Name; 
    envelope.EmailBlurb = 'This is my new eSignature service, it allows me to get your signoff without having to fax, scan, retype, refile and wait forever'; 
    envelope.AccountId = accountId; 

    // Render the contract 
    System.debug('Rendering the contract');  
    PageReference pageRef = new PageReference(url_file_ref); 
    Blob pdfBlob = pageRef.getContent();  

    DocuSignAPI.CustomField field = new DocuSignAPI.CustomField(); 
    field.Name = '##SFLead'; 
    field.Value = lstLead[0].Id; //value of the external source Id 
    field.Show = 'false'; 
    field.CustomFieldType = 'Text';  
    envelope.CustomFields = new DocuSignAPI.ArrayOfCustomField(); 
    envelope.CustomFields.CustomField = new DocuSignAPI.CustomField[1]; 
    envelope.CustomFields.CustomField[0] = field; 

    // Document 
    DocuSignAPI.Document document = new DocuSignAPI.Document(); 
    document.ID = 1; 
    document.pdfBytes = EncodingUtil.base64Encode(pdfBlob); 
    document.Name = 'Annual Contract'; 
    document.FileExtension = 'pdf'; 
    envelope.Documents = new DocuSignAPI.ArrayOfDocument(); 
    envelope.Documents.Document = new DocuSignAPI.Document[1]; 
    envelope.Documents.Document[0] = document; 

    // Recipient   
    System.debug('Building up the recipient'); 
    DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient(); 
    recipient.ID = 1; 
    recipient.Type_x = 'Signer'; 
    recipient.RoutingOrder = 1; 
    recipient.Email = lstLead[0].Email; 
    recipient.UserName = lstLead[0].FirstName + ' ' + lstLead[0].LastName; 

    recipient.RequireIDLookup = false;  

    envelope.Recipients = new DocuSignAPI.ArrayOfRecipient(); 
    envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1]; 
    envelope.Recipients.Recipient[0] = recipient; 

    // Tab 
    DocuSignAPI.Tab tab1 = new DocuSignAPI.Tab(); 
    tab1.Type_x = 'SignHere'; 
    tab1.RecipientID = 1; 
    tab1.DocumentID = 1; 
    tab1.AnchorTabItem = new DocuSignAPI.AnchorTab(); 
    tab1.AnchorTabItem.AnchorTabString = '/t1/'; 
    tab1.AnchorTabItem.XOffset = 100; 


    DocuSignAPI.Tab tab2 = new DocuSignAPI.Tab(); 
    tab2.Type_x = 'DateSigned'; 
    tab2.RecipientID = 1; 
    tab2.DocumentID = 1; 
    tab2.AnchorTabItem = new DocuSignAPI.AnchorTab(); 
    tab2.AnchorTabItem.AnchorTabString = '/d1/'; 

    DocuSignAPI.Tab tab3 = new DocuSignAPI.Tab(); 
    tab3.CustomTabType = 'Text'; 
    tab3.Name = 'Title'; 
    tab3.Type_x = 'Custom'; 
    tab3.RecipientID = 1; 
    tab3.DocumentID = 1; 
    tab3.TabLabel = 'Title'; 
     if(strObjType == 'Lead') 
     { 
      if(lstLead[0].Title != null) 
      { 
       tab3.Value = ''+lstLead[0].Title+''; 
      } 
     } 
     else 
     { 
      if(lstContact[0].Title != null) 
      { 
       tab3.Value = ''+lstContact[0].Title+''; 
      } 
     } 
    tab3.CustomTabWidth=100; 
    tab3.CustomTabRequired=false; 
    tab3.CustomTabLocked=false; 
    tab3.CustomTabDisableAutoSize=false; 
    tab3.TemplateLocked=false; 
    tab3.TemplateRequired=false; 
    tab3.ConditionalParentLabel=''; 
    tab3.ConditionalParentValue=''; 
    tab3.SharedTab=true; 
    tab3.RequireInitialOnSharedTabChange=false; 
    tab3.ConcealValueOnDocument=false; 
    tab3.AnchorTabItem = new DocuSignAPI.AnchorTab(); 
    tab3.AnchorTabItem.AnchorTabString = '/t2/'; 
    tab3.AnchorTabItem.XOffset = 42; 
    tab3.AnchorTabItem.YOffset = -5; 
    tab3.MergeFieldXml = '<mergeField><allowSenderToEdit>true</allowSenderToEdit><configurationType>salesforce</configurationType><path>Lead.Title</path><row>1</row><writeBack>true</writeBack></mergeField>'; 

    envelope.Tabs = new DocuSignAPI.ArrayOfTab(); 
    envelope.Tabs.Tab = new DocuSignAPI.Tab[3]; 
    envelope.Tabs.Tab[0] = tab1;   
    envelope.Tabs.Tab[1] = tab2; 
    envelope.Tabs.Tab[2] = tab3;   

    System.debug('Calling the API'); 
    try { 
     DocuSignAPI.EnvelopeStatus es = dsApiSend.CreateAndSendEnvelope(envelope); 
     envelopeId = es.EnvelopeID; 
     System.debug('Returned successfully, envelope id = ' + envelopeId); 
     return ''; 
    } catch (CalloutException e) { 
    System.debug('Exception - ' + e); 
     envelopeId = 'Exception - ' + e; 
     return ''; 
} 

    return ''; 
    } 
} 
+0

나는 당신이 당신의 코드를 더 제공 좋을 것. – Alan

+0

@Alan 귀하의 의견에 감사드립니다. 나는 내 직책을 정정했다. 나는 그것이 나를 도울 것이고 나는 어떤 조언을 얻을 것이기를 바랍니다. –

답변

0

은 내가 DocuSign의 지원 문제가 해결. SOAP에 대한 MergeFieldXml은 다음과 같이해야합니다 :

tab3.MergeFieldXml ='<mergefieldconfig configversion="1.0" service="salesforce"><mergefield><writeenabled>true</writeenabled><sendercanedit>true</sendercanedit><queryfrom><obj><type>Lead</type><name>Lead</name><field><fieldtype>string</fieldtype><name>Title</name></field></obj></queryfrom></mergefield></mergefieldconfig>'; 
관련 문제