Using Background script I need to create 10 incident records in incident table?

Lucky18
Kilo Contributor

And also out of 10 records 5 records caller id should be one user and the other 5 records should be another user.

As I am new to service now please let me know to code it

Thanks in advnace!

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Shankar,

I have used the following script and the records are created.

 

for(var i = 0 ; i < 5 ; i++)
{
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = '62826bf03710200044e0bfc8bcbe5df1';
gr.insert();
}
for(var i = 0 ; i < 5 ; i++)
{
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = 'a8f98bb0eb32010045e1a5115206fe3a';
gr.insert();
}

 

If the above code doesn't work for you, check for ACLs that might prevent you writing on the field. I ran the above code and records got created. See the attachment.

find_real_file.png

View solution in original post

13 REPLIES 13

Have you changed the sys_ids to users in your environment?

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Community Alums
Not applicable

Hi Shankar,

I have used the following script and the records are created.

 

for(var i = 0 ; i < 5 ; i++)
{
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = '62826bf03710200044e0bfc8bcbe5df1';
gr.insert();
}
for(var i = 0 ; i < 5 ; i++)
{
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = 'a8f98bb0eb32010045e1a5115206fe3a';
gr.insert();
}

 

If the above code doesn't work for you, check for ACLs that might prevent you writing on the field. I ran the above code and records got created. See the attachment.

find_real_file.png

Lucky18
Kilo Contributor

yeah both are working fine as I have tried with catrgory as software its working but this caller id is showing empty

and there is no acl for that field as I can edit it on cell

Lucky18
Kilo Contributor

 yeah Buddies its working now ,i dont know wat I have done is weather right or wrong just instead of sys_id I have given the username

its showing the caller with that name and if i click on that user name uts taking to user form.Any way thnak you everyone!