// GraalJS Script (engine type: 2)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strMultilineText = configs.get( "StrConfA1" ); /// REQUIRED ///////////////
if( strMultilineText === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {A1: Text} is empty \n" );
}
const strPocketSinglelineCsv = configs.getObject( "SelectConfB1" ); /// REQUIRED /////////
const strPocketMultilineCsv = configs.getObject( "SelectConfB2" ); /// REQUIRED /////////
//// == Data Retrieving / ワークフローデータの参照 ==
let strTmp = "";
if( strPocketMultilineCsv !== null ){ // Pocket defined
if( engine.findData( strPocketMultilineCsv ) !== null ){ // Data exists
strTmp = engine.findData( strPocketMultilineCsv );
}
}
//// == Calculating / 演算 ==
/// Replace `,` to ""
let arrText = strMultilineText.replace(/,/g, '').split( "\n" );
/// Append to Tmp
if( strTmp === "" ){
strTmp = arrText.join( "," );
}else{
strTmp = strTmp + "\n" + arrText.join( "," );
}
//// == Data Updating / ワークフローデータへの代入 ==
if( strPocketSinglelineCsv !== null ){
engine.setData( strPocketSinglelineCsv, arrText.join( "," ) );
}
if( strPocketMultilineCsv !== null ){
engine.setData( strPocketMultilineCsv, strTmp );
}
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- When the process arrives, the Text stored in Multiline String data is automatically loaded.
- Comma-separated values in each row are combined.
- If the input text contains commas (`,`), they will be deleted in advance.
- The CSV is output as "the simplest comma-separated string".
- Double quote characters are also preserved unescaped.
- The CSV output has an update mode and an append mode.
- In the append mode, one CSV line is added.
Notes-ja:
- 案件(プロセス)が到達した際、複数行文字列型データに保存されているテキストが読み込まれます。
- 各行の値をカンマ区切りで結合されます。
- 入力テキスト内にカンマ(`,`)が含まれている場合、あらかじめ削除されます。
- 出力されるCSVは「もっともシンプルなカンマ区切り文字列」として出力されます。
- ダブルクオート文字も、エスケープされていない状態で保持されます。
- CSV出力は、更新モードと追記モードがあります。
- 追記モードの場合、CSV行が一行追加されます。
*/