首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docusign嵌入式sigin - Merge字段不工作

Docusign嵌入式sigin - Merge字段不工作
EN

Stack Overflow用户
提问于 2022-04-26 15:39:20
回答 1查看 414关注 0票数 0

我正在使用嵌入签名从salesforce使用顶端工具包。我无法从salesforce合并字段。我正在试着预先确定名字和姓氏。我试过使用定制选项卡和定制字段。自定义选项卡对所有选项卡重复相同的值,而自定义字段不起作用。有人能帮忙吗。

代码语言:javascript
运行
复制
contact c =[select firstName,lastname, Envelope_Id__c from contact where id = :currentUser.contactId]; 
    
    string EnvelopeId='';
      Id mySourceId = currentUser.ContactId; // The ID of the initiating Salesforce object
      String conStr = (String) currentUser.ContactId + '~Contact';
      ContractType__mdt ContractType= [SELECT label, Envelope_Configuration__c,External_Document_Id__c
      FROM ContractType__mdt where Envelope_Configuration__c =:application.Envelope_Configuration__c limit 1];
     string templateId= ContractType.External_Document_Id__c;
     /*
      dfsle.Envelope dsEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
          new dfsle.Entity(mySourceId)) // The initiating Salesforce entity--current SF user (salesperson)
          .withDocuments(new List<dfsle.Document> {
          dfsle.Document.fromTemplate(dfsle.UUID.parse(templateId), description)
          })
          .withRecipients(new List<dfsle.Recipient> {
          dfsle.Recipient.newEmbeddedSigner() // An embedded signer
          }
      );
      if(!Test.isRunningTest()){
      // Send the envelope.
      dsEnvelope = dfsle.EnvelopeService.sendEnvelope(
          dsEnvelope, // The envelope to send
          true // Send now?
      );

      
       EnvelopeId= String.valueOf(dsEnvelope.docuSignId);
      
  }*/


  dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
  new dfsle.Entity(mySourceId));
// The initiating Salesforce entity (an opportunity).


dfsle.Tab myTextFNAMETab = new dfsle.TextTab()
     .withRequired(true) // Signer must enter value
     .withValue(c.firstName)
     .withReadOnly(false)
     .withName('FName')
    // .withAnchor(new dfsle.Tab.Anchor('Legal Name', true, true, null, true, true, 'pixels', 60, -4)); 
    .withPosition(new dfsle.Tab.Position(
      1, // The document to use
      1, // Page number on the document
      149, // X position
      240, // Y position
      80, // 100 pixels wide
      null)); // Default height

      dfsle.Tab myTextLNAMETab = new dfsle.TextTab()
     .withRequired(true) // Signer must enter value
     .withValue(c.lastName)
     .withReadOnly(false)
     .withName('LName')
    // .withAnchor(new dfsle.Tab.Anchor('Legal Name', true, true, null, true, true, 'pixels', 60, -4)); 
    .withPosition(new dfsle.Tab.Position( 
      1, // The document to use
      1, // Page number on the document
      230, // X position
      240, // Y position
      80, // 100 pixels wide
      null)); // Default height

     dfsle.Recipient myRecipient2 = dfsle.Recipient.newEmbeddedSigner();
     myRecipient2.withTabs(new List<dfsle.Tab> {myTextLNAMETab});

  //dfsle.Recipient myRecipient2 = dfsle.Recipient.newEmbeddedSigner();
//add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient2});
myEnvelope = myEnvelope.withEmail('Testt Email Subject', 'Test Email Message');

//myTemplateId contains the DocuSign Id of the DocuSign Template
dfsle.UUID myTemplateId = dfsle.UUID.parse(templateId);

//create a new document for the Envelope
dfsle.Document myDocument = dfsle.Document.fromTemplate(
  myTemplateId, // templateId in dfsle.UUID format
  'Enrollment Agreement'); // name of the template
  dfsle.CustomField myField = new dfsle.CustomField ('text', 'DSFSSourceObjectId', conStr, null, false, false);
//add document to the Envelope
myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument })
.withCustomFields(new List<dfsle.CustomField> {myField});
if(!Test.isRunningTest()){
  myEnvelope = dfsle.EnvelopeService.sendEnvelope(
  myEnvelope, // The envelope to send
  true); // Send now?
EN

Stack Overflow用户

发布于 2022-05-08 23:18:09

我假设您正在尝试填充模板中的现有字段,如果是这样的话:

//这将使用数据标签名称“FName”填充所有字段:

代码语言:javascript
运行
复制
dfsle.Tab prefill_firstname = new dfsle.TextTab()
.withValue(myContact.firstName)
.withDataLabel('FName');

//这将使用数据标签名称‘LName’填充所有字段:

代码语言:javascript
运行
复制
dfsle.Tab prefill_lastname = new dfsle.TextTab()
    .withValue(myContact.lastName)
    .withDataLabel('LName');

//否则,如果只希望创建新收件人的“名&姓”选项卡,而不是填充字段:

代码语言:javascript
运行
复制
dfsle.Tab New_firstname_tab = new dfsle.FirstNameTab()
      .withName('AdditionLastName')
      .withPosition(new dfsle.Tab.Position( 
      1, // The document to use
      1, // Page number on the document
      400, // X position
      240, // Y position
      80, // 100 pixels wide
      null)); // Default height

dfsle.Tab New_lastname_tab = new dfsle.LastNameTab()
      .withName('AdditionLastName')
      .withPosition(new dfsle.Tab.Position( 
      1, // The document to use
      1, // Page number on the document
      500, // X position
      240, // Y position
      80, // 100 pixels wide
      null)); // Default height


dfsle.Recipient myRecipient2 = dfsle.Recipient.newEmbeddedSigner();
  myRecipient2.withTabs(new List<dfsle.Tab> {prefill_firstname,prefill_lastname,New_firstname_tab,New_lastname_tab});
  myRecipient2.withRole('Manager');  // remember to specify the role that match the Role in your template.

至于信封自定义字段:

代码语言:javascript
运行
复制
dfsle.CustomField myField = new dfsle.CustomField ('text', 'DSFSSourceObjectId', conStr, null, false, false);

注意:信封自定义字段在签名会话期间不会直接对收件人可见,因为您已经将显示参数设置为'false',它将不会包含在完成证书中。但是,它仍然可以通过web控制台报告和API:https://www.docusign.com/blog/dsdev-trenches-tabs-and-custom-fields看到。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72016782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档