Questetra BPMS: User, Check Belonging to Role

Questetra BPMS: User, Check Belonging to Role
If the specified user belong to the specified role, this task returns role name. If he or she doesn’t belong to it, it returns nothing.
Configs
  • A1: Select QUSER DATA
  • A2: Edit Target Role Name (eg. Manager,General ) *#{EL}
  • B1: Select STRING DATA for Belonging Role Name
Script (click to open)


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

  //// == Config Retrieving / 工程コンフィグの参照 ==
  const numQuser = configs.get( "conf_Quser" );
  const strRoleNames = configs.get( "conf_Qroles_separating_comma" );
  const numBelongingRoleName = configs.get( "conf_Belonging_Qrole_name" );
  //// == Data Retrieving / ワークフローデータの参照 ==
  const quser = engine.findDataByNumber( numQuser );
  //// == Validation / 入力チェック
  //// == Calculating / 演算 ==
  const arrRoleNames = strRoleNames.split(",");
  const belongRoleObjects = qroleDao.findByQuser( quser );
  let belongingRoleName = "";
  if ( belongRoleObjects !== null){
    for(let i=0; i < arrRoleNames.length; i++){
      engine.log("arrRoleNames[" + i + "] " + arrRoleNames[i]);
      for(let j=0; j < belongRoleObjects.size(); j++){
        engine.log("belongRoleObjects.get(" + j + ") " +  belongRoleObjects.get(j).getName());
        if ( arrRoleNames[i] === belongRoleObjects.get(j).getName()){
          belongingRoleName = belongRoleObjects.get(j).getName();
          break;
        }
      }
      if ( belongingRoleName !== "" ){ break; }
    }
  }
  //// == Data Updating / ワークフローデータへの代入 ==
  engine.setDataByNumber( numBelongingRoleName, new java.lang.String(belongingRoleName) );
} //////// END "main()" /////////////////////////////////////////////////////////////////

Download

2022-10-15 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/questetra-check-belonging-role-202210/
The Addon-import feature is available with Professional edition.
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.

Notes

  • “A2:” Configuration
    • You can specify multiple roles.
      • Affiliation is processed from left to right with the listed roles.
      • Processing ends when affiliation is confirmed

Capture

Leave a Reply

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

Scroll to Top

Discover more from Questetra Support

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

Continue reading