KB0016499 – Format Conversion – Using EMPTY option works during test, not at runtime

Applies to: Ephesoft Transact 4.0 and below

Issue

When attempting to use the Format Conversion plugin to remove any Alphabetic characters and replace them with EMPTY. This feature doesn’t work.

Root Cause

This is a bug and will be fixed in v4.5.

Solution

Use ScriptExtraction.java script for this functionality. cleanUpFields() is the method in the script to replace characters with EMPTY string.

  1. Go to <ephesoft installation>\SharedFolders\<batch class ID>\scripts
  2. Take back up of ScriptExtraction.java file.
  3. Edit the file and add the highlighted line in the execute method.
    public Object execute(Document documentFile, String methodName, String docIdentifier) {
                          Exception exception = null;
                          try {
                                          LOGGER.info("*************  Inside ScriptExtraction scripts.");
                                          LOGGER.info("*************  Start execution of the ScriptExtraction scripts.");
                                          cleanUpFields(documentFile);
                                          if (null == documentFile) {
                                                          LOGGER.error("Input document is null.");
                                          }
                                          boolean isWrite = false;
    
                          // Write the document object to the xml file. Currently following IF block is commented for performance improvement.
                          /*if (isWrite) {                                                                    
                                          writeToXML(documentFile);
                                          LOGGER.info("*************  Successfully write the xml file for the ScriptExtraction scripts.");
                                          LOGGER.info("*************  End execution of the ScriptExtraction scripts.");
                          }*/
                          } catch (Exception e) {
                                          LOGGER.error("*************  Error occurred in scripts." + e.getMessage());
                                          exception = e;
                          }
                          return null;
          }
    

    This is a new method that needs to be added in script. Replace ‘-‘ with the character you want to replace.

    private void cleanUpFields(Document document) { 
                    Element root = document.getRootElement();
                    List docList = root.getChild("Documents").getChildren("Document");
                    for (Element doc : docList) {
                                    List dlf = doc.getChild("DocumentLevelFields").getChildren("DocumentLevelField");
                                    for (int i = 0; i < dlf.size(); i++) {
                                                    Element field = dlf.get(i);
                                                    if (field != null) {
                                                                    Element valueE = field.getChild("Value");                                                                              
                                                                    if (valueE != null) {
                                                                                    String valueT = valueE.getText();                                                                                               
                                                                                    if (!valueT.isEmpty()) {                                                                                                   
                                                                                                    valueT = valueT.replaceAll("-", "");
                                                                                                    valueE.setText(valueT);                                                                                                    
                                                                                    }
                                                                    }
                                                    }
                                    }
                    }
    }

     

  4. Save the file and restart batch.