Questetra BPMS: Process, Concat All Strings
Concatenates all String-type data. Searches and joins string data and title strings stored as workflow data in Questetra BPM Suite. A line break is added between each data which is used for checking the existence of keywords.
Configs
  • A: Select HTTP_Authz Setting *
  • B: Set WF Platform URL (${var[applicationRoot]} or https: //../) *#{EL}
  • C: Set Process ID ( e.g., “123” ) *#{EL}
  • D: Select STRING DATA for Concatenated String (update)
  • E: Select STRING DATA for Concatenated String (new lines added)
Script (click to open)

// about Questetra Workflow API
// See https://online-demo-ja.questetra.net/s/swagger/index.html?urls.primaryName=Workflow%20API
// or "https://{YOUR}.questetra.net/s/swagger/index.html"

// about Questetra OAuth2 (for System Admin)
// Get ID&Secret: System Settings > API Clients > OAuth2 Clients > Add OAuthw Client
// (config "Redirect URL" = "https://s.questetra.net/oauth2callback" )
// (Scope: "read" or "any" )
// Set ID&Secret: Workflow App > Detail > OAuth2 Setting > (Get Refresh Token)


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

//// == Config Retrieving / 工程コンフィグの参照 ==
const strAuthzSetting = configs.get( "AuthzConfA" );           // required
  engine.log( " AutomatedTask Config: Authz Setting: " + strAuthzSetting );
const applicationRoot = configs.get( "conf_ApplicationRoot" ) + "";  // required
const processId       = configs.get( "conf_ProcessId" ) + "";  // required
const dataIdD         = configs.get( "conf_DataIdD" )   + "";  // not required
const dataIdE         = configs.get( "conf_DataIdE" )   + "";  // not required
// 'java.lang.String' (String Obj) to javascript primitive 'string'

engine.log( " AutomatedTask Config: Application Root: " + applicationRoot );
engine.log( " AutomatedTask Config: Process ID: " + processId );


//// == Data Retrieving / ワークフローデータの参照 ==
let concatenatedTextSource = engine.findDataByNumber( dataIdE );

//// == Calculating / 演算 ==
// get ProcessInstance via Questetra Workflow API
// com.questetra.bpms.core.event.scripttask.HttpClientWrapper
let apiRequest = httpClient.begin(); // HttpRequestWrapper
    apiRequest = apiRequest.authSetting( strAuthzSetting ); // with "Authorization: Bearer XX"
    // https://questetra.zendesk.com/hc/en-us/articles/360024574471-R2300#HttpRequestWrapper
    apiRequest = apiRequest.queryParam( "processInstanceId", processId );
const apiUri = applicationRoot + "API/OR/ProcessInstance/view";

// request to API
engine.log( " AutomatedTask Trying: GET " + apiUri );
const response = apiRequest.get( apiUri );
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() + "";
const responseObj = JSON.parse( responseStr );
//engine.log( responseStr );

// retrieve JSON
let concatenatedText = "";
    concatenatedText += responseObj.processInstance.processInstanceTitle + "\n";
for( const key in responseObj.processInstance.data ){
  if( responseObj.processInstance.data.hasOwnProperty(key) ) {
    engine.log( key + ": " + responseObj.processInstance.data[key].dataType );
    if( responseObj.processInstance.data[key].dataType === "STRING" ){
      if( responseObj.processInstance.data[key].value == null ){
        engine.log( " AutomatedTask Json: null string" );
      }else{
        concatenatedText += responseObj.processInstance.data[key].value + "\n";
      }
    }
  }
}
concatenatedText = concatenatedText.replace(/[\n]*$/, "");


//// == Data Updating / ワークフローデータへの代入 ==
if( concatenatedText === "" ){
  engine.log( " AutomatedTask DataUpdating: Concatenated Text empty" );
}
if( dataIdD !== "" ){ 
  engine.setDataByNumber( dataIdD, concatenatedText );
}
if( dataIdE !== "" ){ 
  if( concatenatedTextSource !== null ){
    engine.setDataByNumber( dataIdE, concatenatedTextSource + "\n" + concatenatedText );
  }else{
    engine.setDataByNumber( dataIdE, concatenatedText );
  }
}


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

Download

2021-07-05 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/questetra-bpms-process-concat-all-strings-2021/
The Add-on import feature is available with Professional or Enterprise edition.

Notes

  1. It can also be used as a Data Item for full text search
  2. It supports loop processing
  3. It does not support Discussion type or Table type data

Capture

Concatenates all string type data. Searches and joins string data and title strings stored as workflow data of Questetra BPM Suite. A line break is added between each data. It is used for checking the existence of keywords.

See also

1 thought on “Questetra BPMS: Process, Concat All Strings”

  1. Pingback: Questetra BPMS: Process, Concat All Strings – Questetra Support

Comments are closed.

%d bloggers like this: