// GraalJS Script (engine type: 2)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strCandidateLines = configs.get( "StrConfA" ); /// REQUIRED ///////////
if( strCandidateLines === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {A: String} is empty \n" );
}
let strExtractId = configs.get( "StrConfB" ); // not required ///////
strExtractId = strExtractId.replace(/,/g, '');
engine.log( " AutomatedTask Config: LineId: " + strExtractId );
const strPocketExtracted = configs.getObject( "SelectConfC" ); /// REQUIRED ///////////
//// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)
//// == Calculating / 演算 ==
let arrCandidateLines = strCandidateLines.split("\n");
let numLineId = parseInt( strExtractId, 10 );
if( isNaN(numLineId) ){
numLineId = arrCandidateLines.length - 1;
}else if( numLineId < 0 ){
numLineId = arrCandidateLines.length - 1;
}else if( numLineId > arrCandidateLines.length - 1 ){
numLineId = arrCandidateLines.length - 1;
}
engine.log( " AutomatedTask numLineId: " + numLineId +
" (" + arrCandidateLines.length + ")" );
let strExtracted = arrCandidateLines[ numLineId ];
//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketExtracted, strExtracted );
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- When the process reaches the automated task, the Nth line in the multiline string is extracted.
- You should specify Line-ID `N` as a zero-based integer.
- If you want to extract the first line, specify "`0`".
APPENDIX:
- If the Line-ID contains commas, they will be removed and then parsed.
- Parsing depends on JavaScript `parseInt()`.
- If a line with only line breaks is specified, the single line data will be overwritten with an empty string.
Notes-ja:
- 案件がこの自動処理工程に到達した際、複数行文字列(候補行リスト)内の第N行を自動的に抽出します。
- 行ID `N` はゼロ始まりの整数で指定してください。
- もし先頭行を抽出したい場合は "`0`" を指定します。
APPENDIX-ja:
- 行IDにカンマ(桁区切り文字等)が存在する場合、除去された文字列が解析されます。
- 解析は JavaScript `parseInt()` に依存します。
- 改行のみの行が指定された場合には、単一行文字列データは空文字で上書きされます。
*/