Extracts one user from the members of Qorg in order using a round robin method and sets that user in the Quser data. It is also possible to exclude specific users from the extraction target. If there are no candidates in the population, an error will occur.
Configs
A: Select QORG DATA *
B: If to be excluded, Set in each line (eg “a@example.com”)#{EL}
C: Select QUSER DATA that stores Extracted QUSER (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const qorgPocketPopulation = configs.getObject( "SelectConfA" ); /// REQUIRED ///////////
const strExcludedMembers = configs.get( "StrConfB" ); // not required ////////
const quserPocketSelected = configs.getObject( "SelectConfC" ); /// REQUIRED ///////////
//// == Data Retrieving / ワークフローデータの参照 ==
const qorgPopulation = engine.findData( qorgPocketPopulation );
if( qorgPopulation === null ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Qorg {A} is null \n" );
}
// com.questetra.bpms.core.event.scripttask.WorkflowEngine
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#WorkflowEngine
//// == Calculating / 演算 ==
let listQusers = quserDao.findByQgroup( qorgPopulation );
if( listQusers === null ){
throw new Error( "\n AutomatedTask UnexpectedQorgError:" +
" Qorg {A} has no member \n" );
}
let numOfQusers = listQusers.size() - 0;
// com.questetra.bpms.core.event.scripttask.QuserDaoWrapper
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#QuserDaoWrapper
let arrQusers = [];
for( let i = 0; i < numOfQusers; i++ ){
arrQusers.push( (listQusers.get(i).getEmail() + "") );
// com.questetra.bpms.core.event.scripttask.QuserView
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#QuserView
}
if( strExcludedMembers !== "" ){
let arrExcludedMembers = strExcludedMembers.split('\n');
for( let i = 0; i < arrExcludedMembers.length; i++ ){
let numId = arrQusers.indexOf( arrExcludedMembers[i] );
if( numId > -1 ){
arrQusers.splice( numId, 1 ); // remove 1 element at `numId`
}
}
}
if( arrQusers.length === 0 ){
throw new Error( "\n AutomatedTask UnexpectedQorgError:" +
" Population is Zero \n" );
}
let numSeq = processInstance.getProcessInstanceSequenceNumber() % arrQusers.length;
// com.questetra.bpms.core.event.scripttask.ProcessInstanceView
engine.log( " AutomatedTask numSeq: " + numSeq +
" (" + arrQusers.length + ")" );
let strSelected = arrQusers[ numSeq ];
let quserSelected = quserDao.findByEmail( strSelected );
// com.questetra.bpms.core.event.scripttask.QuserDaoWrapper
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#QuserDaoWrapper
//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( quserPocketSelected, quserSelected );
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
Notes:
- When the process reaches the automated task, the Qorg settings of the Workflow Platform are referred.
- To explicitly and automatically determine the person in charge.
- The Process Status "Offered" is avoided.
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
- In rare cases, it may be assigned consecutively, such as when the number of member changes.
Notes-ja:
- 案件が自動処理工程に到達した際、ワークフロー基盤の Qorg 設定を参照し、一人を抽出します。
- 明示的・自動的に担当者を決めたい場合などに利用されます。
- プロセス状態「引き受け待ち」を回避できます。
APPENDIX-ja:
- 抽出者IDは "プロセス連番" の剰余により算出されます。
- https://questetra.zendesk.com/hc/ja/articles/360007403552-R2011
- 母集団の人数が変動した際などは、連続して割り当てられる可能性があります。
*/
Pingback: Quser, Set One User of Qorg Randomly – Questetra Support
Pingback: Singleline String, Set One Line from Multiline using Round-Robin – Questetra Support