- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 07:53 PM
Hello,
I have a requirement to generate the custom/dynamic task number. I have a custom application where the parent request from creates 9 child tasks (task table is extended from OOB task table) here the child task number should should thing like "TASK- +Parent Number- + 01" the last two digests should go from 01 to 09. Please let me know if this is something doable?
Thanks,
Prudhvi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 09:40 PM
@Community Alums
you can use a flow variable to hold the counter and then re-use it in the next loop.
increment the flow variable with each loop
check this gif below, attaching it again to the comment
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 08:52 PM
@Community Alums
yes this is possible via scripting.
something like this in server side
// Assume parentGr is the GlideRecord of the parent request
var parentNumber = parentGr.number; // Or whatever field holds the parent number
for (var i = 1; i <= 9; i++) {
var childGr = new GlideRecord('x_yourapp_child_task'); // Replace with your table name
childGr.initialize();
childGr.parent = parentGr.sys_id; // Or the relevant parent field
// Generate two-digit sequence
var seq = ('0' + i).slice(-2);
childGr.u_custom_number = 'TASK-' + parentNumber + '-' + seq;
// Set other fields as needed
childGr.insert();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 09:09 PM - edited ‎06-01-2025 09:09 PM
Hi @Ankur Bawiskar - I am creating the task from flow designer and setting few fields from parent to child and trying to set the number value from flow designer script but it's not setting the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 09:40 PM
@Community Alums
you can use a flow variable to hold the counter and then re-use it in the next loop.
increment the flow variable with each loop
check this gif below, attaching it again to the comment
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2025 09:41 PM
Hi @Community Alums ,
In flow designer you have to iterate 9 times and create a record for each iteration, you are just iterating inside a variable and doing some random update, this will not work.
Make sure you design your flow as @Ankur Bawiskar's script.
Thanks,
yaswanth.