- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 01:07 PM
Display Location 'Full Name' in Location Field and Location 'Name' in Building, Floor or Space Field
Hi Guys,
I'm wondering how I can achieve this, I have tried but not succeeded as yet.
On my 'Incident' form, I have configured 3 custom fields, called Building (u_building), Floor (u_floor) and Space (u_space).
They all are Reference fields and reference the standard Location (cmn_location) table.
I also have configured the standard OOTB 'Location' (location) field on the Incident form, which also references the Location (cmn_location) table.
I need to display/show the Location 'Name' value in the Building, Floor and Space fields.
eg
Building is: Derby House
Floor is: 1st Floor
Space is: Meeting Room 101
However, in the 'Location' field, I then need to display/show, the Location 'Full Name' value, for that above chosen Building > Floor > Space (parent-child hierarchy) combination.
eg
Location 'Full Name' is: Derby House/1st Floor/Meeting Room 101
How can I achieve this, as I understand you can only choose one field on the Location table, to be the Display Value (Display Value = True).
So how can I enable/show the Display value to be 'Name' in Building > Floor > Space fields, but 'Full Name' in Location field ?
Is there some way of achieving this guys, either via setting Display value or some script or any other way ?
I always really appreciate the help/guidance - many thanks guys.
(see screenshot attached, showing what my Incident form looks like, for the above).
Warwick
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 01:34 PM
Hi @WazzaJC ,
You can do this with a Client Script:
1.- Go to System Definition -> Client Script.
2.- Click on New
3.- Write a name, select your table, and type on submit.
4.- Add this to your script:
function onSubmit() {
var building= g_form.getValue("u_building");
var floor = g_form.getValue("u_floor");
var space = g_form.getValue("u_space");
var full_name = building + "/" + floor + "/" + space;
g_form.setValue("u_full_location",full_name); //Replace u_full_location with your location value field
}
That would put the full Name field when you update the form.
Hope that would help your.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2023 12:20 AM
Hi @WazzaJC
You need to make some design changes to make it work -
1. Instead of reference fields, change the 3 custom fields to string type - Building (u_building), Floor (u_floor) and Space (u_space).
2. Keep the Location reference field but change its display value to Full Name as instructed by @Marco0o1
3. Now create a on change client script on location field in incident form. The client script will populate the the 3 string fields with their appropriate values based on location selected by user. You can use GlideAjax or g_form.getReference to do it
This design will be able to fulfill all of your requirements
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 01:34 PM
Hi @WazzaJC ,
You can do this with a Client Script:
1.- Go to System Definition -> Client Script.
2.- Click on New
3.- Write a name, select your table, and type on submit.
4.- Add this to your script:
function onSubmit() {
var building= g_form.getValue("u_building");
var floor = g_form.getValue("u_floor");
var space = g_form.getValue("u_space");
var full_name = building + "/" + floor + "/" + space;
g_form.setValue("u_full_location",full_name); //Replace u_full_location with your location value field
}
That would put the full Name field when you update the form.
Hope that would help your.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 02:29 PM
Hi Marco,
Thanks alot for your help.
I have tried this script and it is partially working, however because the 'Location' (location) field is the standard OOTB Location reference field, it is still showing the 'Name' because Name is the Display value for the cmn_location table (not Full Name).
So I am back to the same problem - I need to show/display the Location 'Full Name', not the 'Name' in the Location reference field ?
Thanks, Warwick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 02:40 PM
To modify the display value in a reference field, just follow theses steps:
1.- Type sys_db_object.list in the Applications module
2.- Look for the location table (cmn_location)
3.- Look for the *name fields
4.- Change the display value from name and Full name:
5.- Save
Then you would have your full name field as the display value in a reference field.
Hope that help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 02:44 PM
Hi Marco,
This is exactly back to the same problem however.
If I do this - it changes the Display value for the Building, Floor and Space fields as well.
So we end up showing Full Name, in Building, Floor, Space and Location.
The solution I am trying to achieve is as follows (per my original post):
Building (u_building) field - show 'Name' value
Floor (u_floor) field - show 'Name' value
Space (u_space) field - show 'Name' value
Location (location) field - show 'Full Name' value
Thanks, Warwick