ishant.kesar | Posts: 19

How send custom field information to One Span Signe Label and used as merged field in the template

0 votes

We 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


Duo_Liang | Posts: 3776

Reply to: How send custom field information to One Span Signe Label and used as merged field in the template

0 votes

Hi 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


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off