- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 11:21 PM
I have a requirement where we have a catalog item variable field in that we need to populate the count of group members present in the group.
Basically its having a 2000 - number of members present in group count to show in that field
Can anyone help me with that requirement
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 11:52 PM
I already shared the approach simply subtract
javascript: var count = 0;
var ga = new GlideAggregate('sys_user_grmember');
ga.addQuery('group', 'groupSysId');
ga.addAggregate('COUNT');
ga.query();
if (ga.next()) {
count = parseInt(ga.getAggregate('COUNT'));
}
count = 2000-count;
count;
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
‎07-08-2025 11:46 PM - edited ‎07-08-2025 11:47 PM
No 2000 is a default value we need to subract from the the count of members of assignment group and show it in one variable @anshul_goyal so its 2000- count of member of group = variable field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 11:52 PM
I already shared the approach simply subtract
javascript: var count = 0;
var ga = new GlideAggregate('sys_user_grmember');
ga.addQuery('group', 'groupSysId');
ga.addAggregate('COUNT');
ga.query();
if (ga.next()) {
count = parseInt(ga.getAggregate('COUNT'));
}
count = 2000-count;
count;
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
‎07-09-2025 12:04 AM
@Ankur Bawiskar do i need to do Glideajax and write a client script or directly put in default value of field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 12:05 AM
nothing, simply put that in default value of that string variable
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