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-29-2025 12:37 AM
what does this mean -> global.N.isMemberOf?
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-29-2025 12:38 AM
are you using the correct table name, field name in that?
var grTask = new GlideAggregate("Child table");
grTask.addQuery("request_number", parent.sys_id);
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-29-2025 12:40 AM
Hello @Star123 ,
Use
"gs.getUser().isMemberOf(parent.assignment_group)"
instead of
"global.N.isMemberOf(parent.assignment_group)"
And please mark your question as answered, as it was about checking the number of child tasks, not checking additional conditions.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2025 02:09 AM
try this
1) you are using wrong method for group membership
2) also optimized the code a bit
var answer;
var inactiveStates = ["7", "3", "24", "20"];
if (gs.getUser().isMemberOf(parent.assignment_group) && !inactiveStates.includes(parent.state) && !getAnswer()) {
// Only active true states and not new state
answer = false;
} else {
answer = true;
}
function getAnswer() {
gs.info("my code working");
var lmt = parseInt(gs.getProperty('x_amspi_cpmo_res_0.max_task'));
var grTask = new GlideAggregate("Child table");
grTask.addQuery("request_number", parent.sys_id);
grTask.addAggregate('COUNT');
grTask.query();
var taskCount = grTask.getAggregate('COUNT');
return taskCount < lmt;
}
answer;
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
05-04-2025 08:53 AM
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