Multiline String; Delete Footer Lines
Deletes the Footer lines of a multiline string, like legacy Banking Formats or legacy EDI Data. Note that blank characters at the end or beginning of string data are deleted in advance. If singleline text, an empty string will be returned.
Configs
  • A: Select STRING DATA for Multiline Text *
  • B: Set Number of Footer Lines to Delete (e.g. “1”) *
  • C: Select STRING DATA for Footer-Deleted Text (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
// (c) 2021, Questetra, Inc. (the MIT License)

//////// START "main()" ////////
main();
function main(){ 


//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA = configs.get( "conf_DataIdA" ) + ""; // config required
const delNum  = configs.get( "conf_DelNum" )  + ""; // config required
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // config required
const intDelNum  = parseInt( delNum );
// Design-time Config Format Check
if ( isNaN( intDelNum )){
  throw new Error( "\n AutomatedTask UnexpectedConfigError:" +
                   " Config DelNum is not an integer \n" );
}


//// == Data Retrieving / ワークフローデータの参照 ==
// Run-time Data Format Check
if( engine.findDataByNumber( dataIdA ) === null ){
  throw new Error( "\n AutomatedTask UnexpectedStringError:" +
                   " String {A} is null \n" );
}
const inputText = (engine.findDataByNumber( dataIdA ) + "").trim();
if( inputText === "" ){
  throw new Error( "\n AutomatedTask UnexpectedStringError:" +
                   " String {A} is empty \n" );
}


//// == Calculating / 演算 ==
let   outputText = "";
const arrInputText = inputText.split("\n");
engine.log( " AutomatedTask MultilineString:" + 
            " String {A}, number of lines " + arrInputText.length );
if( arrInputText.length < intDelNum ){
  engine.log( " AutomatedTask StringWarning:" +
    " String {A}, number of lines is smaller than DelNum \n" );
}else{
  for (let i = 0; i < arrInputText.length - intDelNum; i++){
    outputText += arrInputText[i];
    if( i !== arrInputText.length - intDelNum - 1 ){
      outputText += "\n";
    }
  }
}


//// == Data Updating / ワークフローデータへの代入 ==
engine.setDataByNumber( dataIdC, outputText );


} //////// END "main()" ////////

Download

2021-07-13 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/multiline-string-delete-footer-lines-2021/
The Add-on import feature is available with Professional or Enterprise edition.

Capture

See also

%d bloggers like this: