String, Decode using Master Table

String, Decode using Master Table
String, Decode using Master Table

Converts ID string to a Label string by referring to the “Choice Master” shared within the workflow platform. If there is no matching ID, it is converted to an empty string.

(C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/string-decode-using-master-table/

Configs
  • A: Set ID String * #{EL}
  • B: Set Name of Options-XML Master (eg “country-codes.xml” ) * #{EL}
  • C: Select STRING DATA for Decoded Label String (update) *
Script (click to open)

// (c) 2019, Questetra, Inc. (the MIT License)
// Notes:
// id = value, label = display


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

//// == Config Retrieving / 工程コンフィグの参照 ==
const strId      = configs.get( "conf_StrId" ) + "";      // config required
const optionsXml = configs.get( "conf_OptionsXml" ) + ""; // config required
const dataIdC    = configs.get( "conf_DataIdC" ) + "";    // config required
engine.log( " AutomatedTask Config: ID String: " + strId );
engine.log( " AutomatedTask Config: OptionsXML: " + optionsXml );

if( strId === "" ){
  throw new Error( "\n AutomatedTask ConfigError:" +
                   " Config {ID String} is empty \n" );
}
if( optionsXml === "" ){
  throw new Error( "\n AutomatedTask ConfigError:" +
                   " Config {Options-XML} is empty \n" );
}


//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing)


//// == Calculating / 演算 ==
const arrOptions = itemDao.findAll( optionsXml, true );
// return "List<ItemView>" (java.util.ArrayList)
// cf.
// M319: Register an Options-XML file to which the Process Model Definitions Refer
// M319: Options-XML: 複数の業務プロセス定義から参照される選択肢XML
// R2300 com.questetra.bpms.core.event.scripttask.ItemDaoWrapper

let strLabel = "";
const numArrOptionsLength = arrOptions.size() - 0; // Java Long to Javascript number
for( let i = 0; i < numArrOptionsLength; i++ ){
  let tmpId = arrOptions.get(i).getValue() + ""; // Java String to Javascript string
  if( tmpId === strId ){
    strLabel = arrOptions.get(i).getDisplay() + ""; // Java String to Javascript string
    break;
  }
}


//// == Data Updating / ワークフローデータへの代入 ==
if( strLabel === "" ){
  engine.log( " AutomatedTask StringWarning:" +
              " {Decoded Label String} is empty" );
}
engine.setDataByNumber( dataIdC, strLabel );

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

Download

Capture

Converts ID string to Label string with referring "Choice Master" shared within the workflow platform. If there is no matching ID, it is converted to an empty string.

Notes

  1. Options XML Examples

See also

Country Codes

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top