- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:15 PM
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!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2019 12:10 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:20 PM
Hi there,
Something like this?
var callerSysId = '0a826bf03710200044e0bfc8bcbe5d7a,be82abf03710200044e0bfc8bcbe5d1c';
callerSysId = callerSysId.split(',');
for(var i = 0; i < callerSysId.length; i++) {
var loopInt = 5;
for(var j = 0; j < loopInt; j++) {
var grIncident = new GlideRecord('incident');
grIncident.newRecord();
grIncident.setValue('caller_id', callerSysId);
grIncident.insert();
}
}
If my answer helped you in any way, please then mark it as helpful.
Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2020 04:03 PM
this works as intended (ie, caller is populated) when Line 10 is updated to:
grIncident.setValue('caller_id', callerSysId[i]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:39 PM
Yeah its working but the caller id was empty in incident table of all 10 records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:45 PM
That's because the SYS ID Mark Ragavan has used are just sample Sys ID. You need to add the SYS ID of the users you want to create the incidents for. So go to the user for which you want to create incident, copy the SYS ID and substitute the SYS ID in below line:
var callerSysId = '0a826bf03710200044e0bfc8bcbe5d7a,be82abf03710200044e0bfc8bcbe5d1c';