peterzog | Posts: 109

Text Tag Extract + Approvals

0 votes

I 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


Duo_Liang | Posts: 3776

Reply to: Text Tag Extract + Approvals

0 votes

Hi 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


peterzog | Posts: 109

Reply to:

0 votes

Thank 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);

 


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