Text Tag Extract + Approvals
Wednesday, September 29, 2021 at 10:21amI am using the text tag extract example found here: Text Tag Extraction (Apex SDK) | OneSpan Community Platform
and it's working great! I need to layer on an approval so I can send the package.
I noticed that the approvals method needs the fields defined (as shown in the example below):
OneSpanAPIObjects.Approval approval1 = new OneSpanAPIObjects.Approval();
approval1.role = 'firstNamelastName';
approval1.fields = new List<OneSpanAPIObjects.Field> {f1};
How can I pass in the fields that are extracted from the text tags (per the code below from code share)?
//Create Document Metadata
OneSpanAPIObjects.Document document1 = new OneSpanAPIObjects.Document();
document1.name = document1Name;
document1.id = document1Name;
document1.extract = true;
OneSpanAPIObjects.Data data_x = new OneSpanAPIObjects.Data();
data_x.ese_document_texttag_extract_needed = '1';
data_x.esl_doc_extract_type = '1';
document1.data = data_x;
pkg.documents = new List<OneSpanAPIObjects.Document>{document1}; //add document
Reply to: Text Tag Extract + Approvals
Wednesday, September 29, 2021 at 11:30amHi Peter,
I won't think with Text Tags Extraction, you still need to manually pass in field array as the field/signature extraction has been automated.
Hence if you directly set the package status as SENT and invoke the create function, a transaction should have been created and sent out automatically.
//Create package
ESignLiveAPIObjects.Package_x pkg = new ESignLiveAPIObjects.Package_x();
pkg.name = 'Test Text Tags - ' + Datetime.now().format();
pkg.status = ESignLiveAPIObjects.PackageStatus.SENT;
......
//Send package One Step
String packageId = sdk.createPackage(pkg,documentBlobMap);
Duo
Reply to: Hi Peter, I won't think…
Wednesday, September 29, 2021 at 02:55pmThank you for the very fast response. I am new to OneSpan and learning rapidly.
I tried changing the status to sent and I get the following error:
"messageKey":"error.validation.sendPackage.noApprovals","message":"Cannot send package without approvals.","code":400,"name":"Validation Error"}
Do I need to contact support to enable Text Extraction in my org? I saw you mentioned that in another post.
Here is what I am testing:
OneSpanSDK sdk = new OneSpanSDK();
//Create package
OneSpanAPIObjects.Package_x pkg = new OneSpanAPIObjects.Package_x();
pkg.name = 'Test Text Tags - ' + Datetime.now().format();
pkg.autocomplete = true;
pkg.due = System.now().addDays(7);
pkg.status = OneSpanAPIObjects.PackageStatus.SENT;
//Create Roles
String roleId1 = 'signer1';
OneSpanAPIObjects.Role role1 = new OneSpanAPIObjects.Role();
role1.signers = sdk.createRolesSigner('sigenr1_firstname', 'signer1_lastname', '[email protected]', 'CEO', 'ABC Bank');
role1.id = roleId1;
role1.name = roleId1;
pkg.roles = new List<OneSpanAPIObjects.Role>{role1}; //add role
//Prepare Documents Blob
String document1Name = 'Sample_Text_Tag';
StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'sample_contract' LIMIT 1];
Map<String,Blob> documentBlobMap = new Map<String,Blob>();
documentBlobMap.put(document1Name, sr.Body);
//Create Document Metadata
OneSpanAPIObjects.Document document1 = new OneSpanAPIObjects.Document();
document1.name = document1Name;
document1.id = document1Name;
document1.extract = true;
OneSpanAPIObjects.Data data_x = new OneSpanAPIObjects.Data();
data_x.ese_document_texttag_extract_needed = '1';
data_x.esl_doc_extract_type = '1';
document1.data = data_x;
pkg.documents = new List<OneSpanAPIObjects.Document>{document1}; //add document
//Send package One Step
String packageId = sdk.createPackage(pkg,documentBlobMap);
System.debug('PackageId: ' + packageId);