{"id":31689,"date":"2018-11-20T23:26:13","date_gmt":"2018-11-21T07:26:13","guid":{"rendered":"https:\/\/ephesoft.com\/docs\/2019-1-2\/developers\/scripting-guide\/scripting-guide\/"},"modified":"2020-12-08T15:01:10","modified_gmt":"2020-12-08T22:01:10","slug":"scripting-guide","status":"publish","type":"docs","link":"https:\/\/ephesoft.com\/docs\/products\/transact\/developers\/scripting-guide\/scripting-guide\/","title":{"rendered":"Scripting Guide"},"content":{"rendered":"
Scripting functionality in Ephesoft is supported where a custom requirement can be handled. Ephesoft includes power to perform custom functionality during different stages of batch processing. This functionality is supported through the scripts present inside the batch class folder in <\/span>Scripts <\/b>folder. These scripts are Java scripts which access batch.xml through two techniques: DOM Parser and JDOM Parser. All the scripts present should be developed using one of the earlier mentioned parser only.<\/span><\/p>\n This feature is used to provide the roles on the batch instance. If user role have an access to batch instance using batch instance group feature than that batch will display on the BatchList screen. User will able to review\/validate the same batch instance.<\/span><\/p>\n For this feature we are introducing the new database table \u201cbatch_instance_groups\u201d for storing the batch instance identifier and user roles. This table stores all the mapped user roles with the batch instances.<\/span><\/p>\n Database Structure:<\/b><\/p>\n Method for assigning roles in batch instance group table:<\/b><\/p>\n public void assignedBatchInstanceGroup(String batchInstanceIdentifier, String userRole) throws DCMAException<\/span><\/p>\n Configurable parameters:<\/b><\/p>\n Example file:<\/span> ScriptDocumentAssembler_BatchInstanceGroupFeature.java<\/span><\/a><\/p>\n The following is the implementation of the ForceReview feature:<\/span><\/p>\n It is expected that it will be the responsibility of the script to handle the setting of the ForceReview tag in sync with the document validity setting.<\/span><\/p>\n The ForceReview tag of a field will not make a document invalid. It will only prevent a document level field from getting validated(in a document in an invalid state) if set to true.<\/b><\/p>\n This ForceReview tag won\u2019t exist by default(before validation).<\/span><\/p>\n Provided is a sample script for the generation of this ForceReview tag(or modifying it if it is already present) with a value \u201ctrue\u201d for every alternate(note the i+=2 in the script) document level field encountered in a batch.xml.<\/span><\/p>\n Example file:<\/span> Force_Review_Feature_SampleScript.java<\/span><\/a><\/p>\n The Add New Table script is useful for being able to generate a predefined table on the fly in the Validation view.<\/span><\/p>\n Example Scenario:<\/b><\/p>\n If you are processing invoice documents and have defined table extraction during the normal means, it is still possible that if the document is of poor image quality the table you have defined for extraction may not be detected, or may be incomplete. In this case, you can use the Add New Table script to automatically generate a table for your invoice document type with the click of a button. You could create a new empty table of your required structure, or even a populated one… using other extracted values from the documents fields to populate the table values from a database table.<\/span><\/p>\n Example file:<\/span> ScriptAddNewTable.java<\/span><\/a><\/p>\n The Automatic Validation script is executed in the Ephesoft Batch Class workflow prior to reaching the Validation stage. This is the opportune time to implement any custom logic you may require by running verification against the values that have been extracted for the fields defined.<\/span><\/p>\n Example Scenario:<\/b><\/p>\n You may wish to retrieve the extracted value from one field, perhaps a Social Security Number, and use it to perform a look-up operation to an external database, retrieving an associated name. You could then in turn us the results of these SQL query to populate the values of other document level fields defined in Ephesoft.<\/span><\/p>\n Example location: {Ephesoft_install_directory}SharedFoldersBC1scripts<\/span><\/p>\n Example file:<\/span> ScriptAutomaticValidation.java<\/span><\/a><\/p>\n The Document Assembler script is executed in the Ephesoft Batch Class work flow following the Page Processing Module, and Prior to reaching the Document Review stage. At this point the batch .xml has undergone Ephesoft’s classification routines and the batch’s contents are structured into documents, with confidence scores assigned. However, perhaps you have a unique situation where the default Ephesoft classification behavior alone will not organize your batch’s documents as your require. This script is the ideal location to implement any logic to customize the classification organization of your batch. Although Document Level Fields are not yet present in the batch .xml at this point, page level fields are making Script<\/span><\/p>\n Example Scenario:<\/b><\/p>\n You may be using cover sheets to aid in the classification accuracy for your documents. However by the time the work flow reaches the ScriptDocumentAssembler Ephesoft’s classification routines have already worked their magic and you may no longer have any use for the cover sheets. You can use this script to define some logic to remove the first page of every document, which in this case would be the cover sheets.<\/span><\/p>\n We’ve provided as an example resource, a script that does exactly this:<\/span> ScriptDocumentAssembler_remove-1st-page.java<\/span><\/a><\/p>\n The Export script is executed in the Ephesoft Batch Class work flow during the processing of the Export Module. At this point all of Ephesoft’s separation, classification, extraction, and validation have been performed and the batch is in the process of leaving the Ephesoft system. Consequently, ScriptExport.java is the ideal place to implement logic facilitating custom export requirements.<\/span><\/p>\n Example Scenario #1:<\/b> As a batch is leaving the Ephesoft system, you may intend to import its .xml and image files into a document repository system. Your targeted system may have its own internal XML schema for describing its contents, and to make the transition a seamless one you want to consider applying an XSLT translation to the Ephesoft batch .xml so that it can be automatically imported and recognized by its destination system without manual effort.<\/span><\/p>\n Example Scenario #2:<\/b> Perhaps you have a specific document management system such as FileBound in mind. FileBound uses Divider and Separator values to index its contents. Ephesoft provides a FileBound Plugin in the Export Module. However, in addition to this you can implement logic in the ScriptExport.java file to populate the batch documents’ divider and separator fields based on a captured extraction value, barcode, or other means. Through Ephesoft scripting you could use an extracted barcode value as a look up key in a SQL query to an external database table to retrieve the appropriate divider and separator values for a given document type.<\/span><\/p>\n Example location: {Ephesoft_install_directory}SharedFoldersBC1scripts<\/span><\/p>\n Example file:<\/span> ScriptExport.java<\/span><\/a><\/p>\n The Extraction script, although similar in sequence position to the ScriptAutomaticValidation.java, is useful for the purpose of separating extraction from validation.<\/span><\/p>\n Example Scenario:<\/b><\/p>\n Assume you have some OMR field extraction defined to extract check boxes denoting credit card type. For example there could three boxes total, signifying a choice of visa, american express, or mastercard. If filled out correctly the form should only have a check mark in one of the boxes. RecoStar OMR extraction will represent these three check boxes as a three character string of binary values, with the box containing a mark being represented by a “1” value (the others, “0”). Your Extraction script function could analyze the binary values to determine which of the three credit card vendors is being represented and set a document level field value to a string value of “visa”, “amex”, or “mastercard”.<\/span><\/p>\n Example location: {Ephesoft_install_directory}SharedFoldersBC1scripts<\/span><\/p>\n The Field Value Change script can be toggled through the Ephesoft Validation Module, and when enabled will fire when the value of a field is changed in the user Validation View. This can be extremely useful if you want to have the changes you make to one field automatically produce a change in value of one or more other fields.<\/span><\/p>\n Example Scenario #1:<\/b><\/p>\n Consider the case where you have a field that is of the drop down list type. This field contains a list of various departments within an organization (eg: HR, IT, etc). In addition to this field you have another drop down field that serves as a list of users. You can use the Field Change script to implement logic such that change the department value for field #1 will automatically update the drop down list of field #2 with users that correspond to that newly selected department.<\/span><\/p>\n Example Scenario #2:<\/b><\/p>\n Perhaps you have had a document arrive in Validation View with a loan number field that has been extracted, and some corresponding fields that contain information related to the loan number. However, consider if the loan number is incorrect, and your user manually needs to change it. Instead of having to also manually look up and change all of the corresponding fields, the Field Change Value script could make it so that changing the Loan Number field value automatically performs a look up operation to a database and populates the additional fields with the information on file for that loan number.<\/span><\/p>\nBatch Instance Group Feature<\/b><\/h2>\n
Force Review Feature<\/b><\/h2>\n
\n
\n
ScriptAddNewTable.java<\/b><\/h2>\n
ScriptAutomaticValidation.java<\/b><\/h2>\n
ScriptDocumentAssembler.java<\/b><\/h2>\n
ScriptExport.java<\/b><\/h2>\n
ScriptExtraction.java<\/b><\/h2>\n
ScriptFieldValueChange.java<\/b><\/h2>\n