athakka1@partn…

OneSpan SDK to retrieve

0 votes

We're trying to generate the package using template. Templates are created in sandbox.esignlive.com. While generating the package we're receiving below exception, OneSpanRESTAPIHelper.OneSpanRestAPIHelperException: Error updating package with OneSpan: 400 - Bad Request - {"messageKey":"error.validation.packageActivation.unassignedRole","message":"There is a role with no signer.","code":400,"name":"Validation Error"} 


We're executing below code, 

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 = 'hJNKqQncmYMQ'; 
OneSpanAPIObjects.Role role1 = new OneSpanAPIObjects.Role(); OneSpanAPIObjects.Signer signer1 = new OneSpanAPIObjects.Signer(); 
signer1.firstName = 'Mr.'; 
signer1.lastName = 'Ankit'; 
signer1.email = '[email protected]'; signer1.id = placeholder1Id; 
role1.signers = new List<OneSpanAPIObjects.Signer>{signer1}; 
String roleId = role1.Id
role1.id = placeholder1Id; 
pkg.roles = new List<OneSpanAPIObjects.Role>{role1}; 
pkg = sdk.helper.createPackageFromTemplate(pkg,'KpUJgwfBRmR7yX4MsMaJtRFtbzU='); 

//step2: update label fields 
OneSpanAPIObjects.Package_x pack = sdk.getPackage(pkg.id); 
Map<String, String> labelFieldValue = new Map<String, String>{ 'LjIO5N5HRJUK' => 'Ankit Thakkar' }; 
for(OneSpanAPIObjects.Document document: pack.documents){ for(OneSpanAPIObjects.Approval approval: document.approvals){ Boolean isUpdate = false; for(OneSpanAPIObjects.Field field: approval.fields){ system.debug('--> '+field.Id); if(labelFieldValue.containsKey(field.Id)){ isUpdate = true; field.value = labelFieldValue.get(field.Id); } } 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);


Reply to: OneSpan SDK to retrieve

0 votes

Hi Ankit,

 

Thanks for your post! For the given template "KpUJgwfBRmR7yX4MsMaJtRFtbzU=", your placeholder ID should be "bf2d8155-f5e4-4d32-b50e-e64517d1022b", use it as the role ID:

String placeholder1Id = 'bf2d8155-f5e4-4d32-b50e-e64517d1022b'; 

 

Duo

 

 

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: OneSpan SDK to retrieve

0 votes

Hi Duo, Thank you for sharing the Role ID but how I can get it dynamically as we are dealing with 18 different templates?


Reply to: OneSpan SDK to retrieve

0 votes

Hi Ankit,

 

Try using below logic to distinguish placeholder between regular signer:

 

OneSpanSDK sdk = new OneSpanSDK();
OneSpanAPIObjects.Package_x template = sdk.getPackage('ki1AjjsBc9O9bU2k8SFwL3y1i_0=');

List<OneSpanAPIObjects.Role> placeholders = new List<OneSpanAPIObjects.Role>();

for(OneSpanAPIObjects.Role role: template.roles){
   if(role.signers.size() == 0){
       placeholders.add(role);
       System.debug('placeholder.id:' + role.id);
       System.debug('placeholder.name:' + role.name);
   }

}

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


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