Questetra BPMS #Process: Kick HttpStartEvent by TSV
Questetra BPMS: 案件, TSVデータによるHTTP開始イベントのキック
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.
Configs for this Auto Step
- conf_EventUri
- A: Set EventURI (eg. “${var[applicationRoot]}System/…/start”) *#{EL}
- conf_ApiKey
- B: Set ApiKey (32 character key string) *#{EL}
- conf_RestParams
- C: Set Request Params in CSV (eg “title,q_str0,q_num2”) *#{EL}
- conf_StrTsv
- D: Set TSV String that contains the Data to be Thrown *#{EL}
- conf_DataIdI
- i: Select NUMERIC DATA for LineID to be Thrown (as “0” if noset) *
- conf_Increment
- i++: Set “false” if LineID is NOT Incremented after Processing#{EL}
- conf_DataIdJ
- J: Select STRING DATA for Process ID on BPMS (append)
Script (click to open)
//////// 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()" ////////////////////////////////////////////////////////////////
// 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"`)
Download
- Questetra-BPMS-Process-Kick-HttpStartEvent-by-Tsv-2023.xml
- 2023-08-03 (C) Questetra, Inc. (MIT License)
(Installing Addon Auto-Steps are available only on the Professional edition.)
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 to the number of licences + 100 process launches in 15 minutes. (R2170)
- System limit of 500 token transitions. (M204)
- About “HttpStartEvent” [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, the data is completed with an empty string.
- If “HttpStartEvent” is located at the end of the flow, 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”)
Capture
