More than 5 child task should not be allowed to create in related list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 02:30 AM
Hi Everyone.
I have a requirement. we have 1 parent table and 1 child table. in Parent table we have related, from where we are allowing to create child records.
Requirement is New button should get disable or Hide after 7 child records got created for Parent Record.
How we can Achieve this through List UI Control.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 02:58 AM - edited 04-25-2025 02:59 AM
simply add this in the Omit New condition Script field
Give count as 5 or 7 as per your requirement in script. I took 7 for example
If "Omit New condition" field is not on form then Configure Form Layout -> Then add this on form -> Then add script
var parentSysId = parent.sys_id;
var gr = new GlideRecord("childTable"); // your child table name here
gr.addQuery("parentField", parentSysId); // your parent field name here
gr.query();
if (gr.getRowCount() <= 7)
answer = false; // don't omit
else
answer = true; // omit the button
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
04-27-2025 07:48 PM
Hope you are doing good.
Did my reply answer your question?
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
04-25-2025 03:14 AM
Hello @Star123 ,
You can use this "Omit new condition" script. It uses GlideAggregate, which is the faster and recommended way than the old getRowCount() method.
var gaInc = new GlideAggregate('incident');
gaInc.addQuery('parent_incident', parent.getUniqueValue());
gaInc.addAggregate('COUNT');
gaInc.query();
var answer = gaInc.next() ? gaInc.getAggregate('COUNT') >= 7 : false;
answer;
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2025 12:35 AM