- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 07:49 AM
Hello Community,
I have Org Chart working correctly, but find it limiting in that only one field can be displayed at a time. I can change out the 'description' field with any valid column name from the sys_user table and it displays correctly. I want to display title, phone and office in the 'description' field. I've tried parenthesis without success. The only idea I have come up with is to create a new column in sys_user that is a combination of the three fields that I want. Any other ideas? Thanks.
generic_hierarchy.do?sysparm_attributes=record=sys_user,parent=manager,title=name,description=phone,baseid=1axxdcf50x12x20024e25d78a1050efd,levels=2
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 09:27 AM
Hi Richard,
There are two ways to accomplish this: the easy way, and the hard way.
The easy way is to create a new String field with a Calculated value, and use a script in the Calculation field to return the combination of the display values for title, phone and office. Something like:
getTPOValue();
function getTPOValue() {
try {
var fieldValues = [];
fieldValues.push(current.getDisplayValue('title'));
fieldValues.push(current.getDisplayValue('phone_number'));
fieldValues.push(current.getDisplayValue('office'));
return fieldValues.join(' ');
} catch (e) {
gs.log("Unable to calculate TPO for " + current.getValue("user_name") + " : " + e);
return "";
}
}
The upside to this is you can use your new field as the description in your heirarchy by doing nothing more than passing the new field name as the description field in your URL. The downside is this calculation runs every time the user record is queried, which can add overhead.
The hard way is to do this in the UI Page and Script Include that generates the hierarchy. You have two options:
- alter the existing GenericHierarchyProcessor Script Include's _getParams and _newNode methods to be able to split the description value passed in via the URL into the component fields, and look up each of the display values when generating the node.
- copy the generic_hierarchy UI Page and extend the GenericHierarchyProcessor Script Include from a new Include, overriding the methods that deal with getting parameters (_getParams) and generating the node (_newNode).
Each of these ways has their own pros and cons. But either of these methods comes with the advantage of moving the calculation out of GlideRecord, and into the place where it is actually needed. It's an optimization over the calculated field method, but may not be worth the effort to go through. It's likely your instance can handle the calculated value just fine- it's not that hard to compute, and GlideRecords are already optimized to hang around in memory when appropriate. It's just something to consider.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 11:46 AM
Huh...
fieldValues.push('<br>');
This is working as desired in order to insert a new line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:34 PM
Awesome.
Looks like it's reading the value of the field and treating it like HTML. The Javascript that builds those boxes is not easy to dig though, so I'm glad you got it sorted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 09:46 AM
Anurag Tripathi I think you can help here !!