Questetra BPMS #Tasks: Extract by Report ID

Questetra BPMS #Tasks: Extract by Report ID

Questetra BPMS #Tasks: Extract by Report ID

translate Questetra BPMS #タスク処理: レポートIDでデータ抽出

Extracts task (workitem) data via API in TSV format. The data is extracted using the ReportID of the filtered list configured in the Web UI and stored in TSV format. The order of the data columns is configured using a CSV file of data item IDs.

Auto Step icon
Configs for this Auto Step
AuthzConfU
U: Select HTTP_Authz Setting *
StrConfA1
A1: Set Workflow-platform URL (eg. “${var[applicationRoot]}” ) *#{EL}
StrConfA2
A2: Set ReportID (eg. “1234” ) *#{EL}
StrConfA3
A3: Set Max Num of Records (eg. “100” )#{EL}
StrConfB0
B0: Set TSV Column Order using DataItemID (eg “0,1,3,0” ) *#{EL}
SelectConfB1
B1: Select STRING for Extracted TSV (update) *
SelectConfB2
B2: Select NUMERIC for Extracted Count (update)
SelectConfB3
B3: Select NUMERIC for Total Count of List (update)
Script (click to open)
// Script for 'engine type: 3' ("GraalJS standard mode")

//////// START "main()" /////////////////////////////////////////////////////////////////

main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
const objAuthzSetting     = configs.getObject( "AuthzConfU" );   /// REQUIRED ///////////
  engine.log( " AutomatedTask Config: Authz Setting: " + objAuthzSetting.getName() );
const strTargetUrl        = configs.get      ( "StrConfA1" );    /// REQUIRED ///////////
  if( strTargetUrl      === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A1: TargetPlatformURL} is empty \n" );
  }
  if( ! strTargetUrl.endsWith( "/" ) ){
    strTargetUrl += "/";
  }
const strReportId         = configs.get      ( "StrConfA2" );    /// REQUIRED ///////////
  if( strReportId       === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A2: ReportID} is empty \n" );
  }
let   strLimit            = configs.get      ( "StrConfA3" );    // NotRequired /////////
  if( strLimit          === "" ){
      strLimit = "1000";
  }else if( isNaN( parseInt(strLimit, 10) ) || parseInt(strLimit, 10) < 0 ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A3: Max Num of Extraction} must be a positive integer \n" );
  }else if( parseInt(strLimit, 10) > 1000 ){
    engine.log( " AutomatedTask ConfigWarning: " +
                " {A3: Max Num of Extraction} is limited to 1000" );
    strLimit = "1000";
  }
const strColIds           = configs.get      ( "StrConfB0" );    /// REQUIRED ///////////
const strPocketTsv        = configs.getObject( "SelectConfB1" ); /// REQUIRED ///////////
const numPocketExtracted  = configs.getObject( "SelectConfB2" ); // NotRequired /////////
const numPocketFiltered   = configs.getObject( "SelectConfB3" ); // NotRequired /////////

//// == Calculating / 演算 ==
/// Get Workitems
// request1, prepare
let request1Uri = strTargetUrl + "API/OR/Workitem/list";
let request1    = httpClient.begin(); // HttpRequestWrapper
    request1    = request1.authSetting( objAuthzSetting ); // with "Authorization: Bearer XX"
    request1    = request1.queryParam( "reportId", strReportId );
    request1    = request1.queryParam( "limit", strLimit );

// request1, try
const response1     = request1.get( request1Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest1 Start: " + request1Uri );
const response1Code = response1.getStatusCode() + "";
const response1Body = response1.getResponseAsString() + "";
engine.log( " AutomatedTask ApiResponse Status: " + response1Code );
if( response1Code !== "200"){
  throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
                    response1Code + "\n" + response1Body + "\n" );
}

// response1, parse
const response1Obj = JSON.parse( response1Body );
const arrWorkitems = response1Obj.workitems || [];

engine.log( " AutomatedTask Parsed: Number of Received Workitems: " + arrWorkitems.length );
engine.log( " AutomatedTask Parsed: Number of Total Workitems: "    + response1Obj.count );

const arrColIds = parseColumnIds( strColIds );
const strTsv    = buildTsv( arrWorkitems, arrColIds );


//// == Data Updating / ワークフローデータへの代入 ==
engine.setData(   strPocketTsv,       strTsv );
if(               numPocketExtracted  !== null ){
  engine.setData( numPocketExtracted,  new java.math.BigDecimal( arrWorkitems.length ) );
}
if(               numPocketFiltered   !== null ){
  engine.setData( numPocketFiltered,   new java.math.BigDecimal( response1Obj.count ) );
}

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


//// == Sample Response / レスポンスサンプル ================================================
/* 
{
  "count": 55,
  "workitems": [
    {
      "allocateDatetime": "2026-05-29T10:00:17+0900",
      "allocatedQgroupId": 3,
      "allocatedQgroupName": "Sales",
      "allocatedQuserId": 473,
      "allocatedQuserName": "田中 花子",
      "data": {
        "26": {
          "dataType": "DATETIME",
          "id": 143855494,
          "processDataDefinitionNumber": 26,
          "subType": null,
          "value": "2026-05-29 11:00",
          "viewOrder": 28
        },
        "30": {
          "dataType": "STRING",
          "formType": "TEXTFIELD",
          "id": 143855497,
          "processDataDefinitionNumber": 30,
          "subType": null,
          "value": "samplechem202605",
          "viewOrder": 22
        },
        "31": {
          "dataType": "QUSER",
          "formType": "SELECT",
          "id": 143855498,
          "processDataDefinitionNumber": 31,
          "subType": null,
          "value": "田中 花子 \u003Ctanaka.hanako@example.com\u003E",
          "viewOrder": 33
        }
      },
      "directAllocated": true,
      "endDatetime": null,
      "failType": null,
      "id": 144978825,
      "nodeName": "3.実施報告  (見込案件登録)",
      "nodeNumber": 7,
      "offerDatetime": "2026-05-29T10:00:17+0900",
      "parentProcessInstanceId": 2965305,
      "processInstanceDebug": false,
      "processInstanceEndDatetime": null,
      "processInstanceId": 2965365,
      "processInstanceIdForView": "p2965365",
      "processInstanceInitQgroupId": null,
      "processInstanceInitQgroupName": null,
      "processInstanceInitQuserId": null,
      "processInstanceInitQuserName": null,
      "processInstanceSequenceNumber": 1023,
      "processInstanceStartDatetime": "2026-05-21T16:26:51+0900",
      "processInstanceState": "STARTED",
      "processInstanceTitle": "DEMO サンプル化学株式会社 2026-05-29 11:00",
      "processModelId": 143449093,
      "processModelInfoCategory": "5-営業部",
      "processModelInfoId": 3713,
      "processModelInfoName": "552-NEW-Lead-Followup&Demo-fur",
      "processModelVersion": 104,
      "read": false,
      "starred": false,
      "startDatetime": null,
      "state": "ALLOCATED",
      "swimlaneType": "NORMAL",
      "timeLimitDatetime": null
    },
    {
      "allocateDatetime": "2026-05-29T10:00:16+0900",
      "allocatedQgroupId": null,
      "allocatedQgroupName": null,
      "allocatedQuserId": 16,
      "allocatedQuserName": "佐藤 太郎",
      "data": {
        "26": {
          "dataType": "DATETIME",
          "id": 143855494,
          "processDataDefinitionNumber": 26,
          "subType": null,
          "value": "2026-05-29 11:00",
          "viewOrder": 28
        },
        "30": {
          "dataType": "STRING",
          "formType": "TEXTFIELD",
          "id": 143855497,
          "processDataDefinitionNumber": 30,
          "subType": null,
          "value": "samplechem202605",
          "viewOrder": 22
        },
        "31": {
          "dataType": "QUSER",
          "formType": "SELECT",
          "id": 143855498,
          "processDataDefinitionNumber": 31,
          "subType": null,
          "value": "田中 花子 \u003Ctanaka.hanako@example.com\u003E",
          "viewOrder": 33
        }
      },
      "directAllocated": true,
      "endDatetime": null,
      "failType": null,
      "id": 144978807,
      "nodeName": "3b.同席フィードバック",
      "nodeNumber": 37,
      "offerDatetime": "2026-05-29T10:00:16+0900",
      "parentProcessInstanceId": 2965305,
      "processInstanceDebug": false,
      "processInstanceEndDatetime": null,
      "processInstanceId": 2965365,
      "processInstanceIdForView": "p2965365",
      "processInstanceInitQgroupId": null,
      "processInstanceInitQgroupName": null,
      "processInstanceInitQuserId": null,
      "processInstanceInitQuserName": null,
      "processInstanceSequenceNumber": 1023,
      "processInstanceStartDatetime": "2026-05-21T16:26:51+0900",
      "processInstanceState": "STARTED",
      "processInstanceTitle": "DEMO サンプル化学株式会社 2026-05-29 11:00",
      "processModelId": 143449093,
      "processModelInfoCategory": "5-営業部",
      "processModelInfoId": 3713,
      "processModelInfoName": "552-NEW-Lead-Followup&Demo-fur",
      "processModelVersion": 104,
      "read": false,
      "starred": false,
      "startDatetime": null,
      "state": "ALLOCATED",
      "swimlaneType": "NORMAL",
      "timeLimitDatetime": "2026-06-01T11:00:00+0900"
    },
    {
      "allocateDatetime": "2026-05-29T07:56:27+0900",
      "allocatedQgroupId": 3,
      "allocatedQgroupName": "Sales",
      "allocatedQuserId": 16,
      "allocatedQuserName": "佐藤 太郎",
      "data": {
        "26": {
          "dataType": "DATETIME",
          "id": 144974395,
          "processDataDefinitionNumber": 26,
          "subType": null,
          "value": null,
          "viewOrder": 28
        },
        "30": {
          "dataType": "STRING",
          "formType": "TEXTFIELD",
          "id": 144974398,
          "processDataDefinitionNumber": 30,
          "subType": null,
          "value": "sample-lead-001",
          "viewOrder": 22
        },
        "31": {
          "dataType": "QUSER",
          "formType": "SELECT",
          "id": 144974399,
          "processDataDefinitionNumber": 31,
          "subType": null,
          "value": null,
          "viewOrder": 33
        }
      },
      "directAllocated": true,
      "endDatetime": null,
      "failType": null,
      "id": 144974447,
      "nodeName": "0. FollowUp (FirstTouch)",
      "nodeNumber": 63,
      "offerDatetime": "2026-05-29T07:56:27+0900",
      "parentProcessInstanceId": 2976616,
      "processInstanceDebug": false,
      "processInstanceEndDatetime": null,
      "processInstanceId": 2976911,
      "processInstanceIdForView": "p2976911",
      "processInstanceInitQgroupId": null,
      "processInstanceInitQgroupName": null,
      "processInstanceInitQuserId": null,
      "processInstanceInitQuserName": null,
      "processInstanceSequenceNumber": 1047,
      "processInstanceStartDatetime": "2026-05-29T07:56:25+0900",
      "processInstanceState": "STARTED",
      "processInstanceTitle": "LEAD 山田 一郎 2026-05-29 sample-lead-001",
      "processModelId": 144422810,
      "processModelInfoCategory": "5-営業部",
      "processModelInfoId": 3713,
      "processModelInfoName": "552-NEW-Lead-Followup&Demo-fur",
      "processModelVersion": 106,
      "read": false,
      "starred": false,
      "startDatetime": "2026-05-29T08:12:37+0900",
      "state": "STARTED",
      "swimlaneType": "NORMAL",
      "timeLimitDatetime": null
    }
  ]
}
*/



//// == Function Definitions / 関数定義 ================================================

function parseColumnIds( strColIds ){
  if( strColIds === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {B0: TSV Column Order} is empty \n" );
  }

  const arrColIds = strColIds.split( "," ).map(function( strColId ){
    return strColId.trim();
  });

  for( let i = 0; i < arrColIds.length; i++ ){
    if( arrColIds[i] === "" ){
      throw new Error( "\n AutomatedTask ConfigError:" +
                       " Config {B0: TSV Column Order} contains an empty column ID \n" );
    }
  }
  return arrColIds;
}

function buildTsv( arrWorkitems, arrColIds ){
  const arrLines = [];
  for( let i = 0; i < arrWorkitems.length; i++ ){
    const objWorkitem = arrWorkitems[i];
    const arrCells    = [];
    for( let j = 0; j < arrColIds.length; j++ ){
      arrCells.push( stringifyColumn( objWorkitem, arrColIds[j] ) );
    }
    arrLines.push( arrCells.join( "\t" ) );
  }
  return arrLines.join( "\n" );
}

function stringifyColumn( objWorkitem, strColId ){
  if( isWorkitemPropertyName( strColId ) ){
    return sanitizeTsvCell( objWorkitem[strColId] );
  }

  const objDataItems = objWorkitem.data || {};
  if( objDataItems[strColId] === undefined ){
    return "";
  }
  return stringifyDataItem( objDataItems[strColId] );
}

function stringifyDataItem( objDataItem ){
  if( objDataItem === null || objDataItem === undefined ){
    return "";
  }
  if( objDataItem.value === null || objDataItem.value === undefined ){
    return "";
  }

  const strDataType = objDataItem.dataType + "";
  const value       = objDataItem.value;

  if( strDataType === "SELECT" ){
    return sanitizeTsvCell( joinValuesByProperty( value, "display" ) );
  }
  if( strDataType === "FILE" || strDataType === "FILE2" ){
    return sanitizeTsvCell( joinValuesByProperty( value, "name" ) );
  }
  if( strDataType === "QUSER" || strDataType === "QGROUP" ){
    return sanitizeTsvCell( stringifyQuserOrQgroupValue( value ) );
  }
  if( strDataType === "STRING" ||
      strDataType === "DECIMAL" ||
      strDataType === "DATE" ||
      strDataType === "DATETIME" ||
      strDataType === "DISCUSSION" ){
    return sanitizeTsvCell( value );
  }

  return "N/A";
}

function joinValuesByProperty( value, strPropertyName ){
  if( ! Array.isArray( value ) ){
    if( typeof value === "object" && value !== null ){
      return value[strPropertyName] || "";
    }
    return value;
  }

  const arrValues = [];
  for( let i = 0; i < value.length; i++ ){
    if( value[i] !== null && value[i] !== undefined ){
      if( typeof value[i] === "object" ){
        arrValues.push( value[i][strPropertyName] || "" );
      }else{
        arrValues.push( value[i] );
      }
    }
  }
  return arrValues.join( " " );
}

function stringifyQuserOrQgroupValue( value ){
  if( Array.isArray( value ) ){
    const arrValues = [];
    for( let i = 0; i < value.length; i++ ){
      arrValues.push( stringifyQuserOrQgroupValue( value[i] ) );
    }
    return arrValues.join( " " );
  }
  if( typeof value !== "object" || value === null ){
    return value;
  }

  if( value.name    !== undefined && value.name    !== null ){ return value.name;    }
  if( value.display !== undefined && value.display !== null ){ return value.display; }
  if( value.qname   !== undefined && value.qname   !== null ){ return value.qname;   }
  if( value.email   !== undefined && value.email   !== null ){ return value.email;   }

  return JSON.stringify( value );
}

function sanitizeTsvCell( value ){
  if( value === null || value === undefined ){
    return "";
  }
  return ( value + "" ).replace( /\r?\n/g, " " ).replace( /\t/g, " " );
}

function isWorkitemPropertyName( strColId ){
  const objProperties = {
    "allocateDatetime": true,
    "allocatedQgroupId": true,
    "allocatedQgroupName": true,
    "allocatedQuserId": true,
    "allocatedQuserName": true,
    "directAllocated": true,
    "endDatetime": true,
    "failType": true,
    "id": true,
    "nodeName": true,
    "nodeNumber": true,
    "offerDatetime": true,
    "read": true,
    "startDatetime": true,
    "state": true,
    "swimlaneType": true,
    "timeLimitDatetime": true,
    "parentProcessInstanceId": true,
    "processInstanceDebug": true,
    "processInstanceEndDatetime": true,
    "processInstanceId": true,
    "processInstanceIdForView": true,
    "processInstanceInitQgroupId": true,
    "processInstanceInitQgroupName": true,
    "processInstanceInitQuserId": true,
    "processInstanceInitQuserName": true,
    "processInstanceSequenceNumber": true,
    "processInstanceStartDatetime": true,
    "processInstanceState": true,
    "processInstanceTitle": true,
    "processModelId": true,
    "processModelInfoCategory": true,
    "processModelInfoId": true,
    "processModelInfoName": true,
    "processModelVersion": true,
    "starred": true
  };
  return objProperties[strColId] === true;
}

/*
### Notes-en:
- When a Workitem arrives at this Automated Step, an extraction request is sent.
- Target URL requires a trailing `/`.
- The extracted TSV is saved as the "simplest tab-separated string".
- Only the data displayed in the list specified by the `ReportID` will be stored.
- Configure the TSV column order in B0 using Data Item IDs (CSV).
    - Example: `0,47,2,8`
- To store property data of the Task (Workitem) or Case (Process Instance) in a TSV column, set the following variable names instead of the Data Item ID. (Example: `id,state,processInstanceId,0,47`)
    - Workitem ID: `id` (eg: "144978825")
    - Workitem Node/Step Name: `nodeName` (eg: "3.実施報告")
    - Workitem Node/Step Number: `nodeNumber` (eg: "7")
    - Workitem State: `state` (eg: "ALLOCATED")
    - Workitem Allocated User ID: `allocatedQuserId`
    - Workitem Allocated User Name: `allocatedQuserName`
    - Issue ID: `processInstanceId` (eg: "2965365")
    - Title: `processInstanceTitle` (eg: "DEMO サンプル化学株式会社...")
    - ...and other Process Instance properties.

#### Task (Workitem) Properties
- `allocateDatetime`: Task allocation datetime (eg: "2026-05-29T10:00:17+0900")
- `allocatedQgroupId`: Allocated Qgroup ID (eg: "3")
- `allocatedQgroupName`: Allocated Qgroup Name (eg: "Sales")
- `allocatedQuserId`: Allocated Quser ID (eg: "473")
- `allocatedQuserName`: Allocated Quser Name (eg: "SUZUKI, Ichiro")
- `directAllocated`: Direct allocation flag ("true" or "false")
- `endDatetime`: Task end datetime (Processing completed time)
- `failType`: Failure type (null if success)
- `id`: Workitem (Task) ID (eg: "144978825")
- `nodeName`: Step / Node Name (eg: "3.実施報告")
- `nodeNumber`: Step / Node Number (eg: "7")
- `offerDatetime`: Task offered datetime (eg: "2026-05-29T10:00:17+0900")
- `read`: Read flag ("true" or "false")
- `startDatetime`: Task start datetime (Processing started time)
- `state`: Task State (eg: "OFFERED", "ALLOCATED", "STARTED", "ENDED")
- `swimlaneType`: Swimlane Type (eg: "NORMAL")
- `timeLimitDatetime`: Task time limit datetime

#### Case (Process Instance) Properties
- `parentProcessInstanceId`: Parent App Process Instance ID
- `processInstanceDebug`: Debug Mode ("false" or "true")
- `processInstanceEndDatetime`: Case End Datetime
- `processInstanceId`: Case ID (eg: "2965365")
- `processInstanceIdForView`: Case ID with 'p' (eg: "p2965365")
- `processInstanceInitQgroupId`: Starting User's Organization ID
- `processInstanceInitQgroupName`: Starting User's Organization Name
- `processInstanceInitQuserId`: Starting User's User ID
- `processInstanceInitQuserName`: Starting User's User Name
- `processInstanceSequenceNumber`: Sequence Number managed at App level (eg: "1023")
- `processInstanceStartDatetime`: Case Start Datetime (eg: "2026-05-21T16:26:51+0900")
- `processInstanceState`: Case State (eg: "STARTED")
- `processInstanceTitle`: Case Title (eg: "DEMO Sample Chemical...")
- `processModelId`: App ID / Process Model ID
- `processModelInfoCategory`: App Category Name (eg: "5-営業部")
- `processModelInfoId`: App Category ID (eg: "3713")
- `processModelInfoName`: App Name / Process Model Name
- `processModelVersion`: App Version (eg: "104")
- `starred`: App Starred ("false" or "true")

### Notes-ja:
- このアドオン自動工程にタスク(ワークアイテム)が到達した際、抽出リクエストが投げられます。
    - ターゲットとなるワークフロー基盤は URL で設定します。(REST API 接続先)
        - `https://karasuma-oike-000.questetra.net/`
        - 末尾の `/` が必要である点に注意
    - ターゲットとなるワークフロー基盤が同一基盤の場合、[システム変数]による設定で代用可能利です。
        - `${var[applicationRoot]}`
- 抽出TSVは「もっともシンプルなタブ区切り文字列」として格納されます。
    - 各データ内のTABコードや改行コードは " " (半角スペース)に変換されます。
    - ダブルクオート文字も、エスケープされていない状態で保持されます。
- ReportID は、タスクリスト表示時のURI末尾を参照します。
    - `https://example.questetra.net/OR/Workitem/listView?reportId=123456789`
- ReportID で指定したリストに表示されているデータだけが格納されます。(ただし列順不同)
    - TSV列順はデータ項目IDを用いたCSVで設定します。(例: `0,47,2,8`)
    - TSV列にタスク処理のプロパティデータを格納させたい場合、データ項目IDの代わりに次の変数名を設定します。 (例: `id,state,processInstanceId,0,47`)
        - タスクID: `id` (eg: "144978825")
        - 工程名: `nodeName` (eg: "3.実施報告")
        - 工程ナンバー: `nodeNumber` (eg: "7")
        - タスク状態: `state` (eg: "ALLOCATED" または "OFFERED" など)
        - 割当ユーザーID: `allocatedQuserId`
        - 割当ユーザー名: `allocatedQuserName`
        - ケースID: `processInstanceId` (eg:"2965365")
        - 件名: `processInstanceTitle` (eg:"DEMO サンプル化学株式会社...")
        - ...その他プロセスインスタンスプロパティも利用可能です。

#### タスク処理(ワークアイテム)プロパティ】
- タスク割当日時: `allocateDatetime` (例: "2026-05-29T10:00:17+0900")
- 割当組織ID: `allocatedQgroupId` (例: "3")
- 割当組織名: `allocatedQgroupName` (例: "Sales")
- 割当ユーザID: `allocatedQuserId` (例: "473")
- 割当ユーザ名: `allocatedQuserName` (例: "鈴木 イチロー")
- 直接割当フラグ: `directAllocated` ("true" または "false")
- タスク終了日時(処理日時): `endDatetime`
- 失敗タイプ: `failType`
- タスクID: `id` (例: "144978825")
- 工程名: `nodeName` (例: "3.実施報告")
- 工程ナンバー: `nodeNumber` (例: "7")
- 受付開始日時(オファー日時): `offerDatetime` (例: "2026-05-29T10:00:17+0900")
- 既読フラグ: `read` ("true" または "false")
- タスク処理開始日時: `startDatetime`
- タスク状態: `state` (例: "OFFERED", "ALLOCATED", "STARTED", "ENDED", "FAILED")
- スイムレーンタイプ: `swimlaneType` (例: "NORMAL")
- タスク処理期限日時: `timeLimitDatetime`

#### ケース(案件・プロセスインスタンス)プロパティ
- 親アプリのケースID: `parentProcessInstanceId`
- デバッグモード: `processInstanceDebug` ("false" または "true")
- ケース終了時刻: `processInstanceEndDatetime`
- ケースID: `processInstanceId` (例: "2965365")
- ケースID(p付): `processInstanceIdForView` (例: "p2965365")
- 開始ユーザの所属組織ID: `processInstanceInitQgroupId`
- 開始ユーザの所属組織名: `processInstanceInitQgroupName`
- 開始ユーザのユーザID: `processInstanceInitQuserId`
- 開始ユーザのユーザ名: `processInstanceInitQuserName`
- ケース連番(アプリレベルで管理される変数): `processInstanceSequenceNumber` (例: "1023")
- ケース開始日時: `processInstanceStartDatetime` (例: "2026-05-21T16:26:51+0900")
- 状態: `processInstanceState` (例: "STARTED", "ENDED", "FAILED" )
- 件名: `processInstanceTitle` (例: "DEMO サンプル化学株式会社...")
- アプリID: `processModelId` (例: "143449093")
- アプリのカテゴリ名: `processModelInfoCategory` (例: "5-営業部")
- アプリのカテゴリID: `processModelInfoId` (例: "3713")
- アプリ名: `processModelInfoName` (例: "552-NEW-Lead-Followup...")
- アプリバージョン: `processModelVersion` (例: "104")
- アプリの★有無: `starred` ("false" または "true")


### APPENDIX-en
- If the number of tasks of the filter extraction result is 1000 or more, the data after 1001 will not be stored.
    - Even if 1000 or less, there is a possibility of timeout when there are many data items.
    - To control the number of extraction results
        - Extract only the processes whose status status is `Running`
        - Extract only the date data of the previous month
            - After: `#today.addMonths(-1).getFirstTimeInMonth()`
            - Before: `#today.addMonths(-1).getLastTimeInMonth()`
- "HTTP Authorization Setting" is required for automatic communication (OAuth2 API connection).
    - Register [API Client] (OAuth2) in advance as the connection destination. (Requires System Admin privileges)
        - Scope
            - Read-only API Access
        - Redirect URL
            - `https://s.questetra.net/oauth2callback`
        - Make a __note__ of your registration details.
            - Client ID
            - Client Secret (Consumer Secret)
            - Authorization Endpoint URL
            - Token Endpoint URL
    - Set "HTTP Authorization Setting" in the App as client. (Select this setting name in Addon config)
        - Authorization Endpoint URL:
            - _(See your note above)_
            - Example: `https://example.questetra.net/oauth2/authorize`
        - Token Endpoint URL:
            - _(See your note above)_
            - Example: `https://example.questetra.net/oauth2/token`
        - Scope:
            - `read`
        - Client ID
            - _(See your note above)_
        - Client Secret:
            - _(See your note above)_
- Table type data is not supported for extraction.
    - If an unsupported type, "`N/A`" is output.
    - The file names are extracted for the File type. (Multiple: Space-separated)
    - The display strings of the selected options are extracted for the Select type. (Multiple: Space-separated)


### APPENDIX-ja:
- フィルタ抽出結果のタスク処理数(ワークアイテム数)が1000件以上ある場合、1001件以降のデータは格納されません。
    - 抽出結果が1000件以下となる場合でも、データ項目の数が多い場合など、タイムアウトする可能性があります。
    - 抽出結果の数をコントロールする工夫
        - 状態ステータスが `未終了` の案件(プロセス)に絞って抽出する
        - 案件内の日付データが前月のものに絞って抽出する
            - 以降/After: `#today.addMonths(-1).getFirstTimeInMonth()`
            - 以前/Before: `#today.addMonths(-1).getLastTimeInMonth()`
- 自動通信(OAuth2 API接続)のために "HTTP認証設定" が必要です。
    - あらかじめ接続先に、[APIクライアント](OAuth2)を登録します。(システム管理者権限が必要です)
        - スコープ(Scope)
            - データを取得する API へのアクセス / Read-only API Access
        - リダイレクトURL(Redirect URL)
            - `https://s.questetra.net/oauth2callback`
        - 登録内容を __メモ__ します。
            - クライアントID(Client ID)
            - クライアントシークレット(Consumer Secret)
            - 認可エンドポイントURL(Authorization Endpoint URL)
            - トークンエンドポイントURL(Token Endpoint URL)
    - 通信元であるワークフローアプリにて[HTTP認証設定]を設定します。(この設定名をAddonコンフィグで選択)
        - 認可エンドポイント URL:
            - (メモを参照)
            - 例: `https://example.questetra.net/oauth2/authorize`
        - トークンエンドポイント URL:
            - (メモを参照)
            - 例: `https://example.questetra.net/oauth2/token`
        - スコープ:
            - `read`
        - クライアントID
            - (メモを参照)
        - クライアントシークレット:
            - (メモを参照)
- テーブル型データ項目内のデータは抽出サポート外です。
    - サポート外のデータ型は "`N/A`" が出力されます
    - ファイル型を指定した場合、ファイル名が抽出されます(複数:スペース区切り)
    - 選択型を指定した場合、表示テキストが抽出されます(複数:スペース区切り)


*/

Download

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

Notes

  • When a Workitem arrives at this Automated Step, an extraction request is sent.
  • Target URL requires a trailing /.
  • The extracted TSV is saved as the “simplest tab-separated string”.
  • Only the data displayed in the list specified by the ReportID will be stored.
  • Configure the TSV column order in B0 using Data Item IDs (CSV).
    • Example: 0,47,2,8
  • To store property data of the Task (Workitem) or Case (Process Instance) in a TSV column, set the following variable names instead of the Data Item ID. (Example: id,state,processInstanceId,0,47)
    • Workitem ID: id (eg: “144978825”)
    • Workitem Node/Step Name: nodeName (eg: “3.実施報告”)
    • Workitem Node/Step Number: nodeNumber (eg: “7”)
    • Workitem State: state (eg: “ALLOCATED”)
    • Workitem Allocated User ID: allocatedQuserId
    • Workitem Allocated User Name: allocatedQuserName
    • Issue ID: processInstanceId (eg: “2965365”)
    • Title: processInstanceTitle (eg: “DEMO サンプル化学株式会社…”)
    • …and other Process Instance properties.

Task (Workitem) Properties

  • allocateDatetime: Task allocation datetime (eg: “2026-05-29T10:00:17+0900”)
  • allocatedQgroupId: Allocated Qgroup ID (eg: “3”)
  • allocatedQgroupName: Allocated Qgroup Name (eg: “Sales”)
  • allocatedQuserId: Allocated Quser ID (eg: “473”)
  • allocatedQuserName: Allocated Quser Name (eg: “SUZUKI, Ichiro”)
  • directAllocated: Direct allocation flag (“true” or “false”)
  • endDatetime: Task end datetime (Processing completed time)
  • failType: Failure type (null if success)
  • id: Workitem (Task) ID (eg: “144978825”)
  • nodeName: Step / Node Name (eg: “3.実施報告”)
  • nodeNumber: Step / Node Number (eg: “7”)
  • offerDatetime: Task offered datetime (eg: “2026-05-29T10:00:17+0900”)
  • read: Read flag (“true” or “false”)
  • startDatetime: Task start datetime (Processing started time)
  • state: Task State (eg: “OFFERED”, “ALLOCATED”, “STARTED”, “ENDED”)
  • swimlaneType: Swimlane Type (eg: “NORMAL”)
  • timeLimitDatetime: Task time limit datetime

Case (Process Instance) Properties

  • parentProcessInstanceId: Parent App Process Instance ID
  • processInstanceDebug: Debug Mode (“false” or “true”)
  • processInstanceEndDatetime: Case End Datetime
  • processInstanceId: Case ID (eg: “2965365”)
  • processInstanceIdForView: Case ID with ‘p’ (eg: “p2965365”)
  • processInstanceInitQgroupId: Starting User’s Organization ID
  • processInstanceInitQgroupName: Starting User’s Organization Name
  • processInstanceInitQuserId: Starting User’s User ID
  • processInstanceInitQuserName: Starting User’s User Name
  • processInstanceSequenceNumber: Sequence Number managed at App level (eg: “1023”)
  • processInstanceStartDatetime: Case Start Datetime (eg: “2026-05-21T16:26:51+0900”)
  • processInstanceState: Case State (eg: “STARTED”)
  • processInstanceTitle: Case Title (eg: “DEMO Sample Chemical…”)
  • processModelId: App ID / Process Model ID
  • processModelInfoCategory: App Category Name (eg: “5-営業部”)
  • processModelInfoId: App Category ID (eg: “3713”)
  • processModelInfoName: App Name / Process Model Name
  • processModelVersion: App Version (eg: “104”)
  • starred: App Starred (“false” or “true”)

Capture

Appendix

  • If the number of tasks of the filter extraction result is 1000 or more, the data after 1001 will not be stored.
    • Even if 1000 or less, there is a possibility of timeout when there are many data items.
    • To control the number of extraction results
      • Extract only the processes whose status status is Running
      • Extract only the date data of the previous month
        • After: #today.addMonths(-1).getFirstTimeInMonth()
        • Before: #today.addMonths(-1).getLastTimeInMonth()
  • “HTTP Authorization Setting” is required for automatic communication (OAuth2 API connection).
    • Register API Client (OAuth2) in advance as the connection destination. (Requires System Admin privileges)
      • Scope
        • Read-only API Access
      • Redirect URL
        • https://s.questetra.net/oauth2callback
      • Make a note of your registration details.
        • Client ID
        • Client Secret (Consumer Secret)
        • Authorization Endpoint URL
        • Token Endpoint URL
    • Set “HTTP Authorization Setting” in the App as client. (Select this setting name in Addon config)
      • Authorization Endpoint URL:
        • (See your note above)
        • Example: https://example.questetra.net/oauth2/authorize
      • Token Endpoint URL:
        • (See your note above)
        • Example: https://example.questetra.net/oauth2/token
      • Scope:
        • read
      • Client ID
        • (See your note above)
      • Client Secret:
        • (See your note above)
  • Table type data is not supported for extraction.
    • If an unsupported type, “N/A” is output.
    • The file names are extracted for the File type. (Multiple: Space-separated)
    • The display strings of the selected options are extracted for the Select type. (Multiple: Space-separated)

See Also

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading