Converter: Email-String to Quser

Converter: Email-String to Quser

Converter: Email-String to Quser

translate コンバータ: Email文字列 to Quser

Converts an Email string to USER data. If the address is not registered as a user address, an error will occur (USER not updated). If multiple addresses are enumerated in a multiline or comma-delimited string, determined sequentially from the top.

Auto Step icon
Configs for this Auto Step
StrConfA
A: Set Email Address(es) *#{EL}
SelectConfB
B: Select USER DATA (update) *
Script (click to open)
// GraalJS Script (engine type: 2)
// (c) 2023, Questetra, Inc. (the MIT License)

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

////// == Config Retrieving / 工程コンフィグの参照 ==
const strEmails      = configs.get       ( "StrConfA" );          /// REQUIRED
const quserPocket    = configs.getObject ( "SelectConfB" );       /// REQUIRED


////// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)


////// == Calculating / 演算 ==
const arrLines  = strEmails.split ( '\n' );
let quserTmp    = null;

iLoop: for ( let i = 0; i < arrLines.length; i++ ) {
  const arrCols = arrLines[i].split ( ',' );
  for ( let j = 0; j < arrCols.length; j++ ) {
    quserTmp = quserDao.findByEmail ( arrCols[j].trim() );
    // https://support.questetra.com/ja/tips/workflow-script-example/#Handle-QUSER-QGROUP-QROLE
    // com.questetra.bpms.core.event.scripttask.QuserView

    if( quserTmp !== null ) {
      engine.log( " AutomatedTask QuserCheck: found at Line:" + i + "_Col:" + j +
                   " [" + quserTmp.getId() + "] " + quserTmp.getName() );
      break iLoop;
    }
  }
}

if( quserTmp === null ){
  throw new Error( "\n AutomatedTask UnexpectedError: " +
                    "None of the addresses matched QUSER. \n" );
}


//// == Data Updating / ワークフローデータへの代入 ==
if( quserPocket !== null ){
  engine.setData ( quserPocket, quserTmp );
}

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

/*
Notes:
- If you place this "Automated Step" in the Workflow diagram, the script will be executed every time the process token arrives.
- This "Automated Step" converts a string (Email string) to QUSER data.
     - Match with all users registered in the workflow platform.
     - If there are no matching users, this automated step will result in an error.
         - It is also possible to proceed to the "Error Catch Event" (error boundary event).

APPENDIX:
- Whitespace are automatically removed (trimmed) from both ends of an address string.
- Separate multiple addresses with line breaks or commas.
    - No problem, if both are mixed.
- The format `name-addr` is not supported. (eg "`foo <foo@example.com>`")
    - The input value in the format `addr-spec`. (eg "`foo@example.com`")
    - https://datatracker.ietf.org/doc/html/rfc5321
    - https://datatracker.ietf.org/doc/html/rfc5322
- Older version
    - https://support.questetra.com/addons/converter-emailstr-to-quser-2021/

Notes-ja:
- この[自動工程]をワークフロー図に配置すれば、案件が到達する度に既定のスクリプトが実行されます。
- 文字データ(Email文字列)を、ユーザ型データに変換します。
    - ワークフロー基盤内に登録されている全ユーザと照合します。
    - マッチするユーザがいない場合、この自動工程の処理はエラーとなります。
        - 存在しない場合に[エラー境界イベント]に分岐させることも可能です。

APPENDIX-ja:
- アドレス前後の空白文字は自動的に削除(trim)されます。
- 複数アドレスを列挙する場合、改行もしくはカンマで区切ります。
    - 両方が混在していても構いません。
- 書式 `name-addr` には対応していません。(eg "`foo <foo@example.com>`") 
    - 入力値は、書式 `addr-spec` にて記述してください。(eg "`foo@example.com`") 
    - https://datatracker.ietf.org/doc/html/rfc5321
    - https://datatracker.ietf.org/doc/html/rfc5322
- 旧バージョン
    - https://support.questetra.com/ja/addons/converter-emailstr-to-quser-2021/
*/

Download

warning Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.
(Installing Addon Auto-Steps are available only on the Professional edition.)

Notes

  • If you place this Automated Step in the Workflow diagram, the script will be executed every time the process token arrives.
  • This Automated Step converts a string (Email string) to QUSER data.
    • Match with all users registered in the workflow platform.
    • If there are no matching users, this automated step will result in an error.
      • It is also possible to proceed to the “Error Catch Event” (error boundary event).

Capture

Converts an Email string to USER data. If the address is not registered as a user address, an error will occur (USER not updated). If multiple addresses are enumerated in multiline or comma-delimited string, determined sequentially from the top.

Appendix

See Also

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