Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Import set table.

Alex153
Tera Contributor

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

Alex153
Tera Contributor

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"];