Import set table.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 04:17 AM
Hi guys,
I am trying to create import set table using script
var importSetTable = new sn_impex.GlideImportSetTable("Stage_table_81");
//var importsettable = new sn_impex.
importSetTable.addStringColumn('s_column', 50);
//importSetTable.addStringColumn('last name', 50);
var tableStructure = importSetTable.create();
But I got an error "Error: Stage_table_81 is not a valid table"
can you please help with it?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 04:36 AM
Guys,
I found the reason why! My script creates import set table and uses Label name. But ServiceNow or script generates table name randomly, example imp_staging_table_1648638433207. And this name has to be used further.
Do you know how to specify table name. I use this script but it doesn't work
// Create Import Set table
var importSetTable = new sn_impex.GlideImportSetTable("target_table_lable_98");
importSetTable.addStringColumn('id', 40);
importSetTable.addStringColumn('name', 40);
importSetTable.addStringColumn('type', 40);
importSetTable.addStringColumn('typelabel', 40);
importSetTable.addStringColumn('uuid', 40);
tableStructure = {
"tableName": "u_target_table_lable_98",
"tableLabel": "target_table_lable_98" + 'Label',
"columns": {
"first name": "u_first_name",
"last name": "u_last_name",
"start date": "u_start_date"
}
}
var tableStructure = importSetTable.create();
var importSetTableName = tableStructure["tableName"];
var importSetTableName = tableStructure["tableLable"];
var columns = tableStructure["columns"];