How to insert 1000 records in incident table

Amulya Pallapo1
Giga Contributor

I need 1000 records inserted in my incident table in PDI, how can I get it ?

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey @Amulya Pallapothula 

You can create run a for loop:

for(var i = 0 ; i < 1000 ; i++){
var gr = new GlideRecord('incident');
gr.newRecord();
gr.caller_id = gs.getUserID();
gr.short_description = "Created by BG script";
gr.description = "Created by BG script - index of records "+ i;
gr.insert();
}

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

View solution in original post

10 REPLIES 10

SumanthDosapati
Mega Sage
Mega Sage

Hi @Amulya Pallapothula ,

If you have those 1000 incident details in an excel sheet then use 'Import Set' to import data to a table.

 

Regards,

Sumanth

Hi Sumanth,

I dont have records in excel as well, then from where I can get 1000 records?

 

Regards,

Amulya

Navigate to 'Scripts - Background' from left navigator and write below script

for(var i = 0 ; i < 100 ; i++)
{
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'Created from Script';
gr.description = Math.random().toString(36);  //it will create random string
gr.insert();
}

 

Mark as correct and helpful if it solved your query.

Regards,

Sumanth

dmathur09
Kilo Sage
Kilo Sage

Hi Amulya,

You can write a background script to create a new incident with all the relevant field. Use a for loop to run the script 1000 times.

Regards,

Deepankar Mathur