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

Community Alums
Not applicable

Hi,

You can use below script to add 1000 records 

 

var shortDesc = ['Email is not working', 'Hardware Issue', 'Software Issue', 'Password Reset', 'Attendance Regularization', 'Forget Id card '];

for(var i=0; i<1000; i++){
var shortDescRandom;
shortDescRandom = shortDesc[Math.floor(Math.random()*shortDesc.length)];
gs.print("shortDescRandom = " + shortDescRandom);
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = shortDescRandom;
gr.update();
}

 

Thanks 

Sarthak