Converter: Quser to Email-String
Converter: Quser to Email-String

Converts Quser type data to Email string by referencing the latest information registered in the Workflow Platform. It is also possible to obtain “User ID”, “User Name”, “Main Organization”, “ID of Main Organization”, “Name of Main Organization”.

2020-02-18 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/converter-quser-to-email-string/

Configs
  • A: Select USER DATA *
  • B: Select STRING DATA for User Email Address (update)
  • C: Select STRING DATA for User ID (update)
  • D: Select STRING DATA for User Name (update)
  • E: Select ORG DATA for Main Organization of User (update)
  • F: Select STRING DATA for ID of Main Organization (update)
  • G: Select STRING DATA for Name of Main Organization (update)
  • H: Select STRING DATA for Email of Main Organization (update)
Script
// Notes:
// "Email of the organization to which the user belongs primarily" may be an empty.
// 
// Notes (ja):
// 「ユーザの主として属する組織のメールアドレス」は空文字列となっている場合があります

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

//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA = configs.get( "conf_DataIdA" ) + ""; // required
const dataIdB = configs.get( "conf_DataIdB" ) + ""; // not required
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // not required
const dataIdD = configs.get( "conf_DataIdD" ) + ""; // not required
const dataIdE = configs.get( "conf_DataIdE" ) + ""; // not required
const dataIdF = configs.get( "conf_DataIdF" ) + ""; // not required
const dataIdG = configs.get( "conf_DataIdG" ) + ""; // not required
const dataIdH = configs.get( "conf_DataIdH" ) + ""; // not required
// 'java.lang.String' to javascript primitive 'string'


//// == Data Retrieving / ワークフローデータの参照 ==
if( engine.findDataByNumber( dataIdA ) === null ){
  throw new Error( "\n AutomatedTask UnexpectedQuserError:" +
                   " Quser {A} is null \n" );
}
const quser = engine.findDataByNumber( dataIdA );
// 'com.questetra.bpms.core.event.scripttask.QuserView'
// https://questetra.zendesk.com/hc/en-us/articles/360024574471-R2300


//// == Calculating / 演算 ==
const strQuserEmail    = quser.getEmail() + "";
const strQuserId       = quser.getId()    + ""; // java.lang.Long to string
const strQuserName     = quser.getName()  + "";
const qorgQuserMainOrg = qgroupDao.findPrimaryQgroup( quser );
// com.questetra.bpms.core.event.scripttask.QgroupDaoWrapper
const strQuserMainOrgId    = qorgQuserMainOrg.getId()    + ""; // java.lang.Long to string
const strQuserMainOrgName  = qorgQuserMainOrg.getName()  + "";
let   strQuserMainOrgEmail = "";
if( qorgQuserMainOrg.getEmail() === null ){
  engine.log( " AutomatedTask QorgDataCheck:" + 
              " Qorg '" + strQuserMainOrgName + "' has no Email Info" );
}else if( qorgQuserMainOrg.getEmail() + "" === "" ){
  engine.log( " AutomatedTask QorgDataCheck:" + 
              " Qorg '" + strQuserMainOrgName + "' has not Email Info" );
}else{
  strQuserMainOrgEmail = qorgQuserMainOrg.getEmail();
}


//// == Data Updating / ワークフローデータへの代入 ==
if( dataIdB !== "" ){ 
  engine.setDataByNumber( dataIdB, strQuserEmail );
}
if( dataIdC !== "" ){ 
  engine.setDataByNumber( dataIdC, strQuserId );
}
if( dataIdD !== "" ){ 
  engine.setDataByNumber( dataIdD, strQuserName );
}
if( dataIdE !== "" ){ 
  engine.setDataByNumber( dataIdE, qorgQuserMainOrg );
}
if( dataIdF !== "" ){ 
  engine.setDataByNumber( dataIdF, strQuserMainOrgId );
}
if( dataIdG !== "" ){ 
  engine.setDataByNumber( dataIdG, strQuserMainOrgName );
}
if( dataIdH !== "" ){ 
  engine.setDataByNumber( dataIdH, strQuserMainOrgEmail );
}

} //////// END "main()" ////////////////////////////////////////////////////////////////

Download

Capture

Converts Quser type data to Email string by referencing the latest information registered in the Workflow Platform. It is also possible to obtain "User ID", "User Name", "Main Organization", "ID of Main Organization", "Name of Main Organization".

Notes

  1. “Email of the organization to which the user belongs primarily” may be an empty.

See also

1 thought on “Converter: Quser to Email-String”

  1. Pingback: Converter (Quser to ID, Name, Email) – Questetra Support

Leave a Reply

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

%d bloggers like this: