how can a program create a staging table for import of many rows?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2023 07:59 AM
I'm trying to write a program (as opposed to a human running this manually) that can import to an existing target table. The Import Set API insertMultiple feature seems to be the only efficient way (please correct if wrong) to import many records to a target table. Import Set API requires a staging table, and a transform map to specify how to transform records from the staging table into the target table.
Here's my question: how would such a program (using REST API's in particular) create an empty staging table? The Table REST API has a "create" function, but that means to "create" a row, not to "create" the table.
I've started experimenting with creating tables manually, but see no way to do this from a program (using REST API's). Related to this, some tables (like "Incident") don't appear to be extensible, so manually creating a new table derived from "Incident" (to serve as a staging table for import to "Incident") seems unnecessarily difficult. One can extend Task, but not Incident (which extends Task). Am I missing something? (Yes, a second question...)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2023 08:03 AM
What is your end goal?
Why are you trying to do this?
If you want to use a web service, why will the default table web services not work for what you are trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2023 08:11 AM
HI @Dave Oshinsky ,
I trust you are doing great.
To accomplish this, you would follow these steps:
- Use the Table API's "create" function to define a new table based on "Task" or any other appropriate parent table. This will create an empty table with the desired fields and properties.
POST /api/now/table/sys_db_object
{
"name": "u_staging_table",
"label": "Staging Table",
"extends": "task"
}
Once the staging table is created, you can configure the transform map to specify how records from the staging table should be transformed into the target table, such as "Incident".
You can now use the Import Set API's "insertMultiple" feature to efficiently import multiple records from the staging table to the target table. This API requires the name of the staging table and the transform map to be provided.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2023 08:22 AM
Hi Amit,
That sounds like a great way to do this for an extensible table like Task. When I tried to extend Incident, I didn't see it in the list of extensible tables. So, for a non-extensible table, I take it that the complete list of columns would need to be specified when posting to sys_db_object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2023 10:20 AM