Converter (Email-Str to Quser)

Converter (Email-Str to Quser)

Converts string type data (email string) to Quser type data. If it does not match any registered address, the user type data item will not be updated. When multiline string, it is judged in order from the first line until it matches.

2019-09-09 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/converter-emailstr-to-quser/

Configs
  • A: Select STRING DATA for Email Address *
  • B: Select USER DATA (update) *
Script
// (c) 2019, Questetra, Inc. (the MIT License)

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

//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA = configs.get( "conf_DataIdA" ) + "";
const dataIdB = configs.get( "conf_DataIdB" ) + "";
// 'java.lang.String' (String Obj) to javascript primitive 'string'

//// == Data Retrieving / ワークフローデータの参照 ==
const strInput = engine.findDataByNumber( dataIdA ) + "";
const arrStrInput = strInput.split("\n");
engine.log( " AutomatedTask StringDataCheck:" + 
            " String {A}: " + arrStrInput.length + " line(s)" );

//// == Calculating / 演算 ==
let quser = quserDao.findByEmail( arrStrInput[0] );
// 'com.questetra.bpms.core.event.scripttask.QuserView'
// NULL if Not Found
if( quser != null ){
  engine.log( " AutomatedTask QuserCheck:" + 
              " found at #1 [" + quser.getId() + "] " + 
              quser.getName() );
}
if( quser == null && arrStrInput.length > 0 ){
  for(let i = 1; i < arrStrInput.length; i++){
    quser = quserDao.findByEmail( arrStrInput[i] );
    if( quser != null ){ 
      engine.log( " AutomatedTask QuserCheck:" + 
                  " found at #" + (i+1) + " [" + quser.getId() + "] " + 
                  quser.getName() );
      break; 
    }
  }
}

//// == Data Updating / ワークフローデータへの代入 ==
if( quser != null ){
  engine.setDataByNumber( dataIdB, quser );
}else{
  engine.log( " AutomatedTask QuserCheck:" + 
              " Quser not found");
}

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

Download

Capture

See also

M209: Nomination by Organization and by Role

1 thought on “Converter (Email-Str to Quser)”

  1. Pingback: Converter (Email-Str to Quser) – Questetra Support

Leave a Reply

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

%d bloggers like this: