- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi, I need to insert multiple records into a table in ServiceNow. I have around 40–50 values (like short descriptions for Incidents), and adding them one by one will take a lot of time. Is there any way I can paste all my values into a script and insert them into the table at once?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Jimmy,
Yes, you can definitely insert multiple records at once using a background script in ServiceNow. You just need to adjust the table name and the field names according to your instance. Here’s an example you can use:
// Replace 'your_table_name' with the table you want to insert into
var records = [
"Keyboard not working",
"Mouse not responding",
"VPN disconnecting frequently",
"Software update failed",
"Printer offline",
"Phone voicemail setup",
"Network printer access"
];
for (var i = 0; i < records.length; i++) {
var gr = new GlideRecord('your_table_name'); // your table
gr.initialize();
gr.your_field_name = records[i]; // replace with your field
// Optional: set other fields if needed
// gr.category = "inquiry";
gr.insert();
}
gs.print(records.length + " records inserted successfully!");
Just make sure to replace your_table_name with the actual table (like incident or any custom table) and also replace your_field_name with the field you want to populate (like short_description).
This way, you can easily paste 40–50 values and insert them all at once without doing it manually.
Thanks & Regards,
Muhammad Iftikhar,
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Jimmy,
Yes, you can definitely insert multiple records at once using a background script in ServiceNow. You just need to adjust the table name and the field names according to your instance. Here’s an example you can use:
// Replace 'your_table_name' with the table you want to insert into
var records = [
"Keyboard not working",
"Mouse not responding",
"VPN disconnecting frequently",
"Software update failed",
"Printer offline",
"Phone voicemail setup",
"Network printer access"
];
for (var i = 0; i < records.length; i++) {
var gr = new GlideRecord('your_table_name'); // your table
gr.initialize();
gr.your_field_name = records[i]; // replace with your field
// Optional: set other fields if needed
// gr.category = "inquiry";
gr.insert();
}
gs.print(records.length + " records inserted successfully!");
Just make sure to replace your_table_name with the actual table (like incident or any custom table) and also replace your_field_name with the field you want to populate (like short_description).
This way, you can easily paste 40–50 values and insert them all at once without doing it manually.
Thanks & Regards,
Muhammad Iftikhar,
If my response helped, please mark it as the accepted solution so others can benefit as well.