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. Multiline strings are judged in order from the first line until it matches.
Configs
  • A: Select STRING DATA for Email Address *
  • B: Select USER DATA (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
// (c) 2021, 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

2021-07-08 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/converter-emailstr-to-quser-2021/
The Add-on import feature is available with Professional edition.

Capture

See also

M209: Nomination by Organization and by Role

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

  1. Pingback: Converter: Quser to Email-String – Questetra Support

Comments are closed.

%d bloggers like this: