
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 02:28 AM
Hi,
Im trying to get the full name when choosing several parent in a field the has tree_picker = true;
for example: The location field is configured as a tree by default so when you choose a a city for example you get just the name of the city but you have configured your field by (location.full_name) you get the city and its country.
do you have any idea how i can do that please.
thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 11:01 AM
Hi Adil,
I have implemented in my local system and everything is working fine.
Please find the details of the implementation -
The table definition as follows - Parent field should have an attribute tree_picker = true
The Full Name column should be calculated and code should be like this -
FYI, the code below -
(function() {
var resultName = current.u_name;
var parentId = current.u_parent;
if (!gs.nil(parentId)) {
var grParent = new GlideRecord('u_location_sri'); //write your table here
grParent.addQuery('sys_id', parentId);
grParent.query();
if (grParent.next()) {
resultName = grParent.u_full_name +"/"+current.u_name;
}
}
return resultName;
})()
I have inserted few records to test the functionality and everything is working fine -
I think your issue is resolve, hopefully
Mark if it is correct or helpful.
Tomorrow, I will try to give you the details of creating the table without column name starting with 'u_'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 08:07 AM
My bad, I am sorry for misunderstanding, at this point I am afraid to look like a dumb person, if I dont understand any more
You want the same way how location has full name getting calculated and you want the same way it has to be calculated for your field too -
Have you saw the business rule on Location table - out of box BR
Please have mercy if I again misunderstood you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 08:27 AM
thank you so much this is so helpful, i needed just to know this "GlideHierarchicalReference()"
i did the same thing as in location - generate full name, but i don't know how to implemente it , i mean how the system gonna refer that script to the field full name ? do you have any idea !?
thank you so much !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 08:42 AM
I am relieved that I understood you finally, Don't worry, you dont have to implement anything, its platform defined java file and function. Just use the code as shown, it will automatically query your parent field and start to build the full name recursively.
Its a Glidescriptable function, so use the same script, I think that will work fine I guess. One catch is the field name should be 'name' and parent field should have field name as 'parent'.
The field name shouldn't have u_name or u_parent I guess, anyhow try once and let me know.
Mark if it is helpful or correct, feedback is appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 09:05 AM
I had tryed the script but my fields were begening by a "u_" .
the problem now is i can't make columns names without "u_".
i understood from what you said that the system can recognize my fields by names using that script. is it true ?
i have tryed to delete all fields and create it again without "u_" but the system generate that after saving, any help please.
thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 09:28 AM
This script should help you - select the full name as calculated field - and put this script in the calculation -
var fullName = getFullName(current);
function getFullName(gr){
var resultName;
var fName = gr.u_name;
var parentId = gr.u_parent;
if (!gs.nil(parentId)) {
var grParent = new GlideRecord('location'); //write your table here
grParent.query('sys_id', parentId);
grParent.query();
if (grParent.next()) {
resultName = grParent.u_fullname +"/"+gr.u_name;
}
}
resultName;
}
fullName;
Mostly this should work
Mark if it is helpful or correct, feedback is appreciated