- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 12:30 AM - edited 08-03-2024 08:57 AM
I want to display the hierarchical structure of a group in a cool and beautiful tree form. (tree picker was not good enough)
If possible, it would be great if I could also see the members connected to the group at a glance!
I want to utilize generic_hierarchy after looking at the following page, but for some reason I get an error.
What I want to do is to graphically represent the parent-child hierarchy of groups.
If you can achieve that in your report, please let me know how to do that as well!
https://www.servicenow.com/community/platform-analytics-forum/visualize-group-hierarchy/m-p/1219909
I am asking because I have been checking and trying as much as I can on the community postings and it is not working.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 10:40 AM
It has solved itself and I am putting the script on here, although there is still room for improvement.
UI Action
Show update:true
Form link:True
Action name:GroupHierarchy
var currentGroupId = current.getValue('sys_id');
var parentGroupId = findTopParentGroup(currentGroupId);
function findTopParentGroup(groupId) {
var gr = new GlideRecord('sys_user_group');
if (gr.get(groupId)) {
while (gr.getValue('parent')) {
gr.get(gr.getValue('parent'));
}
return gr.getValue('sys_id');
}
return null;
}
if (parentGroupId) {
var url = "generic_hierarchy.do";
url += "?sysparm_stack=no";
url += "&sysparm_attributes=record=sys_user_group,";
url += "parent=parent,";
url += "title=name,";
url += "description=manager,";
url += "baseid=" + parentGroupId;
gs.setRedirect(url);
} else {
gs.addErrorMessage("Top parent group not found.");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 04:54 AM
There is no OOB way to do this in ServiceNow.
Next to that: why are you posting the same question in the same forum twice, using 2 accounts? You are wasting time of people trying to help you and don't know what solution was already provided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 08:52 AM - edited 08-03-2024 08:53 AM
I accidentally posted it on one account and immediately deleted it, but I guess I didn't delete it.
I am sorry for taking up your and everyone's valuable time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2024 10:40 AM
It has solved itself and I am putting the script on here, although there is still room for improvement.
UI Action
Show update:true
Form link:True
Action name:GroupHierarchy
var currentGroupId = current.getValue('sys_id');
var parentGroupId = findTopParentGroup(currentGroupId);
function findTopParentGroup(groupId) {
var gr = new GlideRecord('sys_user_group');
if (gr.get(groupId)) {
while (gr.getValue('parent')) {
gr.get(gr.getValue('parent'));
}
return gr.getValue('sys_id');
}
return null;
}
if (parentGroupId) {
var url = "generic_hierarchy.do";
url += "?sysparm_stack=no";
url += "&sysparm_attributes=record=sys_user_group,";
url += "parent=parent,";
url += "title=name,";
url += "description=manager,";
url += "baseid=" + parentGroupId;
gs.setRedirect(url);
} else {
gs.addErrorMessage("Top parent group not found.");
}