ポータルの画面からCSVインポートを行いたい
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:13 AM
コミュニティの皆様
いつもお世話になっております。
私はサービスポータルの画面からCSVデータをアップロードして、
テーブルにインポートしたいと考えております。
PDIでDataSouceを作成し、テーブル(Incidentは例です)にインポートできることは確認済です。
(設定内容はスクリーンショットをご確認ください)
イメージとしては
①Record Producerを作成
②Variables(TypeはAttachment)を追加
③Record Producer scriptで以下処理を記載
・DataSourceの添付ファイルにCSVを配置
・DataSourceのLoad All Recordsを実行
・Transform MapでTransformを実行
のような形で考えておりますが、③について、サンプルコードなど前例があればご教示頂きたいです。
よろしくお願いいたします。
▼Data Source
▼CSV
▼Groupテーブル
▼Transform Map
▼インポート後のIncident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 03:16 PM
Hi d-aizawa,
As an option, I would suggest that you create a flow to perform the following:
- Lookup the data source record (alternatively create / update the data source record if not present)
- Remove the previous attachments from this record (if any) so that you don't import old data
- Attach the new file to the data source record
- Trigger a Custom Flow Action to do the following in a script step:
- Lookup the transform maps for the import set table
- Load the data into the import set table
- Run the transform Map(s) to transform the data from the import set table into the target table(s)
Here is a code example for triggering a data source and its related transform maps:
var importSetTableName = '<name_of_import_set_table>';
var transformMaps = [];
// Lookup transform maps for a given import set table
var transformMapGr = new GlideRecord('sys_transform_map');
transformMapGr.addActiveQuery();
transformMapGr.addQuery('source_table', importSetTableName);
transformMapGr.orderBy('order');
transformMapGr.query();
while (transformMapGr.next()) {
transformMaps.push(transformMapGr.getUniqueValue());
}
// Load the data into the import set table
var loader = new GlideImportSetLoader();
var importSetGr = loader.getImportSetGr(dataSourceGr);
loader.loadImportSetTable(importSetGr, dataSourceGr);
importSetGr.state = 'loaded';
importSetGr.update();
// Transform the data from the import set table into the target table
var transformWorker = new GlideImportSetTransformerWorker(importSetGr.sys_id, transformMaps.join());
transformWorker.setBackground(true);
transformWorker.start();