Limit the number of related records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 10:33 PM
Hello Everyone,
I'd like to know if there's an elegant way of limiting the number of children tasks that can be linked to a parent?
Currently there's no limitation, such that users can link 5000> tasks to a single record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 11:02 PM
Hi @myusufk90 ,
Unfortunately, you can't control it and you can certainly start to see performance issues when that many records are part of a related list.
What you can do , you can use the Preferences from your profile and work with the related list dispaly to On demand:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 11:11 PM
Hello @myusufk90
Elegant way will be to create a BR on child task table.
Now for example if I write a BR on Catalog Task [sc_task] table which is child for Requested Item [sc_req_item] and I would like to limit it with 5 max then my Before Insert/Update BR will be as below.
var maxChildTasks = 5; // Set your desired limit here
var parentRequestId = current.request_item.sys_id;
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', parentRequestId);
gr.query();
if (gr.getRowCount() >= maxChildTasks) {
gs.addErrorMessage('You cannot link more than ' + maxChildTasks + ' child tasks to a single service request.');
current.setAbortAction(true);
}
This script checks the number of child tasks already linked to the parent service request and prevents adding more if the limit is reached.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.