Create multiple no. Of records from record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 12:45 PM
Hi Community,
I have a requirement
As we know that record producer can generate one new record after clicking on submit button. Record producer is create on incident table.I have add one variable in here that is 'how many records should be create' with name 'inc_create. There is another field name assign to that has map to assigned to in incident table. If we write 3 here then three new incident records should be create and assigned to should be autopopulate to these newly created records.
Thanks in Advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 12:46 PM
Hi there,
Can you share what you tried and what is not working?
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
07-11-2023 01:12 PM - edited 07-11-2023 01:12 PM
Hi @Mark Roethof,
these variables are created for Record Producer
1) how many records should be created
2)Assigned_to
the RP links to the incident table and creates a new incident record with auto-population of the assigned to variable.
the requirement is to create multiple records of incidents (the no. write on the first variable)and assigned to variable should also be present on these newly created incident records.
I've tried this code but this is not working:
var num_rec = parseInt(current.variables.inc_create);
var f1 = current.assign;
for (var i = 0; i < num_rec; i++) {
var rec = new GlideRecord('incident');
rec.initialize();
rec.assign_to = f1 + ' ' + (i + 1);
rec.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 10:51 PM
"I've tried this code but this is not working:"
Please be more specific. What is not working?
Apart from that, it looks like you are inserting additional incidents, though with only 1 field (assign_to), rest will be blanc/default (or generation might be aborted due to missing values)?
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
07-12-2023 01:30 AM
Hi @Mark Roethof, I want to create multiple number of records by using above code. Assign to field should be autopopulate on these incident records. And number Field should be increment.