How send custom field information to One Span Signe Label and used as merged field in the template
Friday, February 18, 2022 at 10:29amWe have a template in eSign which uses custom label to populate values in the document with signer information e.g signer DOB, SSN. Currently our user use bulk file upload feature to create multiple packages for each signer in the One Span Application. Currently, there is no connection between the One Span application and Salesforce. We aren't going to install the One Span connector as well. We will be using Apex SDK for the integration.
The requirement in Salesforce is that we retrieve the template from One Span to Salesforce via API call (template should have a placeholder signer), the using post request, we want to create transaction with the template in One Span, also replaces the signer. The challenge is I need to send some custom field information to One Span and map with label information in Signer (similar to bulk recipient sheet).
I need to find a way through which I can send custom field and map with label (in signer information) via API call
Reply to: How send custom field information to One Span Signe Label and used as merged field in the template
Friday, February 18, 2022 at 11:12amHi ishant.kesar,
If I understand you correctly, you meant you have a template with a placeholder recipient and multiple label fields, where #1 the placeholder needs to be replaced by real signer and #2 the label fields need to be pre-set values.
Assuming the label fields are with field names of "DOB" and "SSN", please check below sample codes and see if this fits your requirement:
public static void test220218(){
OneSpanSDK sdk = new OneSpanSDK();
//step1: create a transaction out of the template
OneSpanAPIObjects.Package_x pkg = new OneSpanAPIObjects.Package_x();
pkg.name = 'TEST';
pkg.description = 'TEST';
String placeholder1Id = 'cc503b32-3477-42ad-9a22-51b85cce748a';
OneSpanAPIObjects.Role role1 = new OneSpanAPIObjects.Role();
OneSpanAPIObjects.Signer signer1 = new OneSpanAPIObjects.Signer();
signer1.firstName = 'Mr.';
signer1.lastName = 'Bean';
signer1.email = '[email protected]';
signer1.id = placeholder1Id;
role1.signers = new List<OneSpanAPIObjects.Signer>{signer1};
role1.id = placeholder1Id;
pkg.roles = new List<OneSpanAPIObjects.Role>{role1};
pkg = sdk.helper.createPackageFromTemplate(pkg, 'KhUqcyU9b8KTxjNxyxxutbJMkBQ=');
//step2: update label fields
OneSpanAPIObjects.Package_x pack = sdk.getPackage(pkg.id);
Map<String, String> labelFieldValue = new Map<String, String>{
'DOB' => '1993/01/01',
'SSN' => '123-123-12344'
};
for(OneSpanAPIObjects.Document document: pack.documents){
for(OneSpanAPIObjects.Approval approval: document.approvals){
Boolean isUpdate = false;
for(OneSpanAPIObjects.Field field: approval.fields){
if(labelFieldValue.containsKey(field.name)){
isUpdate = true;
field.value = labelFieldValue.get(field.name);
}
}
if(isUpdate){
sdk.updateApproval(pkg.id, document.id, approval.id, approval);
}
}
}
//step 3:send the transaction
pack.status = OneSpanAPIObjects.PackageStatus.SENT;
sdk.updatePackage(pack, pack.id);
}
Duo