Task numbers are not auto incremented
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 03:56 AM
Hi,
I have created a business rule to auto create 5 incident tasks when certain conditions are met.
But 5 incident tasks have the task number.
Please check and advise how i can get different numbers for each incident task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 04:55 AM
Hi,
I have created After BR on Incident table with insert selected.
Script:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 11:40 AM - edited 10-09-2023 11:43 AM
The current script will create five records in the 'incident_task' table, but because 'incGr' is not created inside the loop, all of these records will have the same values.
If you want each record to have different values, you make the following changes:
for (var i = 0; i < 5; i++) {
var incGr = new GlideRecord('incident_task');
incGr.initialize();
incGr.incident = current.sys_id;
incGr.cmdb_ci = current.cmdb_ci;
incGr.short_description = current.short_description + " Task " + (i + 1); // Add a unique number to the short description
incGr.insert();
}