我正在使用嵌入签名从salesforce使用顶端工具包。我无法从salesforce合并字段。我正在试着预先确定名字和姓氏。我试过使用定制选项卡和定制字段。自定义选项卡对所有选项卡重复相同的值,而自定义字段不起作用。有人能帮忙吗。
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?
发布于 2022-05-08 23:18:09
我假设您正在尝试填充模板中的现有字段,如果是这样的话:
//这将使用数据标签名称“FName”填充所有字段:
dfsle.Tab prefill_firstname = new dfsle.TextTab()
.withValue(myContact.firstName)
.withDataLabel('FName');
//这将使用数据标签名称‘LName’填充所有字段:
dfsle.Tab prefill_lastname = new dfsle.TextTab()
.withValue(myContact.lastName)
.withDataLabel('LName');
//否则,如果只希望创建新收件人的“名&姓”选项卡,而不是填充字段:
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.
至于信封自定义字段:
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看到。
https://stackoverflow.com/questions/72016782
复制相似问题