// 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" );
}
const strExclusionPatterns = configs.get( "StrConfB" ); // not required ///////
const strPocketExtracted = configs.getObject( "SelectConfC" ); /// REQUIRED ///////////
//// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)
//// == Calculating / 演算 ==
let arrExclusionPatterns = strExclusionPatterns.split("\n"); // empty returns [ '' ]
let arrCandidateLines = strCandidateLines.split("\n");
let arrCandidateLinesExcluded = [];
for( let i = 0; i < arrCandidateLines.length; i++ ){
if( arrCandidateLines[i] === "" ){
arrCandidateLinesExcluded.push( arrCandidateLines[i] );
continue;
}
let boolMatch = false;
for( let j = 0; j < arrExclusionPatterns.length; j++ ){
if( arrExclusionPatterns[j] === "" ){ break; }
if( arrCandidateLines[i].includes( arrExclusionPatterns[j] ) ){
boolMatch = true;
break;
}
}
if( ! boolMatch ){
arrCandidateLinesExcluded.push( arrCandidateLines[i] );
}
}
if( arrCandidateLinesExcluded.length === 0 ){
throw new Error( "\n AutomatedTask UnexpectedStringError:" +
" Population is Zero \n" );
}
let numSeq = processInstance.getProcessInstanceSequenceNumber() % arrCandidateLinesExcluded.length;
// com.questetra.bpms.core.event.scripttask.ProcessInstanceView
engine.log( " AutomatedTask numSeq: " + numSeq +
" (" + arrCandidateLinesExcluded.length + ")" );
let strExtracted = arrCandidateLinesExcluded[ numSeq ];
//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketExtracted, strExtracted );
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- When the process reaches the automated task, one line in the multiline string is extracted.
- If the multiline string contains a blank line, a blank line (empty string) may be extracted.
- If you want to delete blank lines in advance, place an Automated Task upstream.
- Multiline String, Delete Empty Lines
- https://support.questetra.com/ja/addons/multiline-string-delete-empty-lines-2021/
- Please set the exclusion setting (detection pattern) for each line: multiple patterns can be set.
- If no the exclusion setting (detection pattern), one line is extracted from all candidate lines.
- If a blank line is set in the exclusion setting (detection pattern), it will be ignored.
APPENDIX:
- The extractor ID is calculated from the remainder of the "Process Sequence Number".
- https://questetra.zendesk.com/hc/en-us/articles/360007403552-R2011-Properties-of-Workflow-App
- Process Sequence Number
- In-app serial number that is added each time a new process is started.
- Select Daily, Monthly, or Yearly, to be reset to zero automatically at regular intervals.
Notes-ja:
- 案件がこの自動処理工程に到達した際、複数行文字列(候補行リスト)内の一行を自動的に抽出します。
- 空行を含む複数行文字列の場合、空行(空文字列)が抽出される可能性があります。
- あらかじめ空行を削除しておきたい場合、上流に自動削除工程を配置します。
- 複数行文字列, 空行の削除
- https://support.questetra.com/ja/addons/multiline-string-delete-empty-lines-2021/
- 除外設定(検出文字パターン)は、各行に設定してください(複数のパターンを設定できます)
- 除外設定(検出文字パターン)が未設定の場合、全ての候補行から一行抽出されます。
- 除外設定(検出文字パターン)に空行が設定された場合、無視されます。
APPENDIX-ja:
- 抽出IDは "プロセス連番" の剰余により算出されます。
- https://questetra.zendesk.com/hc/ja/articles/360007403552-R2011
- プロセス連番
- 新しいプロセスが起動されるたびに加算されるアプリローカルな通し番号
- 自動的にゼロリセットされるよう設定することも可能です(日次・月次・年次)
*/