Display Location 'Full Name' in Location Field and Location 'Name' in Building, Floor or Space Field

WazzaJC
Tera Expert

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

2 ACCEPTED SOLUTIONS

Marco0o1
Tera Sage

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.

 

View solution in original post

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 

View solution in original post

6 REPLIES 6

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 

Many thanks Manmohan, much appreciated.