Questetra BPMS: Process, Kick HttpStartEvent by TSV
Questetra BPMS: Process, Kick HttpStartEvent by TSV

Kicks HttpStartEvent with the specific line data of TSV. When assuming batch start using multiline TSV data, place it in a loop structure. LineIDs start at zero.

(C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/questetra-bpms-process-kick-httpstartevent-by-tsv/

Configs
  • A: Set EventURI (eg. “${var[applicationRoot]}System/…/start”) * #{EL}
  • B: Set ApiKey (32 character key string) * #{EL}
  • C: Set Request Params in CSV (eg “title,q_str0,q_num2”) * #{EL}
  • D: Set TSV String that contains the Data to be Thrown * #{EL}
  • i: Select NUMERIC DATA for LineID to be Thrown (as “0” if noset) *
  • i++: Set “false” if LineID is NOT Incremented after Processing #{EL}
  • J: Select STRING DATA for Process ID on BPMS (append)
Script (click to open)

// Notes:
// Throw POST-Request to "HttpStartEvent" in Questetra BPMS workflow.
// Supports loop processing (Bulk Start) Increment of Line ID / Appends BPMS ProcessID started
// The line data in the TSV will be thrown. (eg "title={Ai} q_str0={Bi} q_num2={Ci}")
// System limit of "Number of License + 100", Process start in every 15 minutes (R2170)
// System limit of "transition of tokens up to 500 times". (M204)
// About "HttpStartEvent" [Message Start Event (HTTP)]
// - https://questetra.zendesk.com/hc/en-us/articles/360002245432-M221
// - https://support.questetra.com/bpmn-icons/message-start-event-http/
// Request parameter is configured in CSV format. (eg "title,q_str0,q_num2")
// If #of Cols of TSV data is less than #of parameters, complemented with an empty string.
// If "HttpStartEvent" located at the most downstream, transfer data can be implemented.
// MultilineString type, Files type not supported.
// Data Format https://questetra.zendesk.com/hc/en-us/articles/360016441572-R2210
// The thousands separator for numeric data must be removed. (eg. "1234.56")
// 
// Notes (ja):
// Questetraワークフロー内の "HTTP開始イベント" に POST-Request を投げます。
// ループ処理に対応します(一括起動) 指定する行IDのインクリメント/開始されたProcessIDの追記
// TSV内の指定行にあるデータが送出されます(例 "title={Ai} q_str0={Bi} q_num2={Ci}")
// 「15分間に『ライセンス数 + 100』プロセス起動」のシステム制限があります。(R2170)
// 「トークンの遷移は500回まで」のシステム制限があります。(M204)
// "HTTP開始イベント" [メッセージ開始イベント(HTTP)] について
// - https://questetra.zendesk.com/hc/ja/articles/360002245432-M221
// - https://support.questetra.com/ja/bpmn-icons/message-start-event-http/
// RequestパラメータはCSV形式で設定します(例 "title,q_str0,q_num2")
// TSVデータの横要素数がパラメータ数に足りない場合、空文字列で補完されます。
// "HTTP開始イベント" を最下流に配置しておけば、移行データの流し込みにも応用できます。
// 複数行文字列・ファイル型データは投入できません。
// 送信データのFormat https://questetra.zendesk.com/hc/ja/articles/360016441572-R2210
// 数値型データの桁区切り文字は除去しておく必要があります。 (eg. "1234.56")

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

//// == Config Retrieving / 工程コンフィグの参照 ==
const eventUri   = configs.get( "conf_EventUri"  )  + ""; // required
const apiKey     = configs.get( "conf_ApiKey" )     + ""; // required
const restParams = configs.get( "conf_RestParams" ) + ""; // required
const strTsv     = configs.get( "conf_StrTsv" )     + ""; // required
const dataIdI    = configs.get( "conf_DataIdI" )    + ""; // required
const increment  = configs.get( "conf_Increment" )  + ""; // not required
const dataIdJ    = configs.get( "conf_DataIdJ" )    + ""; // not required

engine.log( " AutomatedTask Config: Event URI: " + eventUri );
if( increment === "false" || increment === "FALSE" ){
  engine.log( " AutomatedTask Config: Increment: " + increment );
}else{
  engine.log( " AutomatedTask Config: Increment: true" );
}


//// == Data Retrieving / ワークフローデータの参照 ==
let intLineId = 0;
if( engine.findDataByNumber( dataIdI ) !== null ){
  intLineId = engine.findDataByNumber( dataIdI ) - 0;
  // convet 'java.math.BigDecimal' to 'javascript number'
}
let strBpmsProcessIds = "";
if( dataIdJ !== "" ){
  if( engine.findDataByNumber( dataIdJ ) !== null ){
    strBpmsProcessIds = engine.findDataByNumber( dataIdJ ) + "";
  }
}


//// == Calculating / 演算 ==
// REST Parameters
let arrRestParams = restParams.split(",");
engine.log( " AutomatedTask Config: RestParams: " + restParams );
engine.log( " AutomatedTask: #of RestParams: " + arrRestParams.length );

// Data to Throw
const arrStrTsv = strTsv.split("\n");
engine.log( " AutomatedTask MultilineString:" + 
            " TSV {D}, #of lines: " + arrStrTsv.length );
engine.log( " AutomatedTask Thrown Data:" + 
            " LineID " + intLineId + ": " + arrStrTsv[intLineId] );
const arrThrow = arrStrTsv[intLineId].split("\t");

// POST-Request to HttpStartEvent
// com.questetra.bpms.core.event.scripttask.HttpClientWrapper
let apiRequest = httpClient.begin(); // HttpRequestWrapper
    apiRequest = apiRequest.formParam( "key", apiKey );
    for( let j = 0; j < arrRestParams.length; j++){
      if( j < arrThrow.length ){
        apiRequest = apiRequest.formParam( arrRestParams[j], arrThrow[j] );
      }else{
        apiRequest = apiRequest.formParam( arrRestParams[j], "" );
      }
    }

// request to API
engine.log( " AutomatedTask Trying: POST " + eventUri );
const response = apiRequest.post( eventUri );
const responseCode = response.getStatusCode() + "";
engine.log( " AutomatedTask ApiResponse: Status " + responseCode );
if( responseCode !== "200"){
  throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
         responseCode + "\n" + response.getResponseAsString() + "\n" );
}
const responseStr = response.getResponseAsString() + "";
engine.log( " AutomatedTask BPMS-ProcessID:" + 
            responseStr );
if( strBpmsProcessIds === "" ){
  strBpmsProcessIds = responseStr;
}else{
  strBpmsProcessIds += "\n" + responseStr;
}


//// == Data Updating / ワークフローデータへの代入 ==
if( increment === "false" || increment === "FALSE" ){
  engine.log( " AutomatedTask LoopSupport: (LineID not incremented)" );
}else{
  intLineId = intLineId + 1;
  engine.setDataByNumber( dataIdI, new java.math.BigDecimal( intLineId ) );
  engine.log( " AutomatedTask LoopSupport: LineID incremented to " + intLineId  );
}
if( dataIdJ !== "" ){
  engine.setDataByNumber( dataIdJ, strBpmsProcessIds );
}

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

Download

Capture

Kicks HttpStartEvent with the specific line data of TSV. When assuming batch start using multiline TSV data, place it in a loop structure. LineIDs start at zero.

Notes

  1. Throw POST-Request to “HttpStartEvent” in Questetra BPMS workflow.
  2. Supports loop processing (Bulk Start) Increment of Line ID / Appends BPMS ProcessID started
  3. The line data in the TSV will be thrown. (eg “title={Ai} q_str0={Bi} q_num2={Ci}”)
  4. System limit of “Number of License + 100”, Process start in every 15 minutes (R2170)
  5. System limit of “transition of tokens up to 500 times”. (M204)
  6. About “HttpStartEvent” [Message Start Event (HTTP)]
    1. https://questetra.zendesk.com/hc/en-us/articles/360002245432-M221
    2. https://support.questetra.com/bpmn-icons/message-start-event-http/
  7. Request parameter is configured in CSV format. (eg “title,q_str0,q_num2”)
  8. If #of Cols of TSV data is less than #of parameters, complemented with an empty string.
  9. If “HttpStartEvent” located at the most downstream, transfer data can be implemented.
  10. MultilineString type, Files type not supported.
  11. Data Formats https://questetra.zendesk.com/hc/en-us/articles/360016441572-R2210
    1. The thousands separator for numeric data must be removed. (eg. “1234.56”)

See also

1 thought on “Questetra BPMS: Process, Kick HttpStartEvent by TSV”

  1. Pingback: Connector (TSV Bulk Start) – Questetra Support

Leave a Reply

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

%d bloggers like this: