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-06-2023 08:30 AM - edited 10-06-2023 08:31 AM
Hi,
If you want to continue the incident task numbering that is already present in the system, you need to ensure that your business rule for auto-creating incident tasks is aware of the current task numbering sequence and continues from there. Here are the steps to achieve this:
Identify the Current Highest Task Number: Determine the highest task number currently in your incident tasks table (usually the "Number" field). You can find this by running a query or report to identify the last used task number.
Modify Your Business Rule Logic: In your business rule script, you should increment this highest task number by 1 to generate the next task number. Here's an example in JavaScript for a business rule script:
var gr = new GlideRecord('task');
gr.addQuery('task_table', 'incident_task');
gr.orderByDesc('number');
gr.query();
if (gr.next()) {
var currentMaxNumber = parseInt(gr.number);
var nextNumber = currentMaxNumber + 1;
// Set the next task number for the newly created incident task
current.number = nextNumber.toString();
}
By following above steps, your business rule will ensure that the newly created incident tasks continue from the highest task number already present in the system. This way, you'll have a consistent sequence of task numbers without any duplicates.
If your problem is solved then please mark it helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 09:22 AM
Hello,
This sounds like a potential bug in your logic.
An 'insert' into the 'incident_task' table should provide you with a unique number upon insertion.
Could you please share your code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 04:50 AM
Hi Cristian,
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-06-2023 09:39 AM
Hi there,
There is auto-number out-of-the-box on Incident Tasks. Is that also on your instance?
Can you also share details about your business rule? It might be scripting issue, for example when using autoSysFields(false).