How to get value of dot walking field in client script?

Shivam7
Tera Contributor

How to get value of dot walking field in client script?

14 REPLIES 14

Harsh Vardhan
Giga Patron

use g_scratchpad or ajax here to get dot walk field value. 

 

 

Service_RNow
Mega Sage

Hi,

To get values of the dot walking fields of country and city as shown in the picture using "g_form.getValue('location.country');".

In a similar way if you want to perform any action on the above two country and city fields while writing code use names as "location.country" and "location.city".

After going throw this Mark it Correct/helpful, if this helps you
Thank you

Really not sure why this got to be the top rated answer. It is the wrong answer. Please think carefully before posting on the Community as wrong answers can cause great confusion for newcomers. 

For anyone who stumbles on this you cannot dot walk that way in Client Script.

You will either need to use getReference with a call back function 

or

GlideAjax to get a reference fields related field value.

Using GlideAjax is preferable due to performance improvement (due to reduced n/w traffic being transferred) over getReference even if it uses a callback. 

If the reference field you need the value for is not going to change on the form once loaded, you could also use a Display Business Rule and set g_scratchpad value there. 

 

PS: DO NOT use GlideRecord Client Side to get reference field related field values. Trust me your instance and user base will thank you for not doing that!

Dot Walking levels: The recommended maximum is 3 although you can go deeper if you really must. 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

FYI, you can use g_form.getValue("parent.child") in a client script, I do it all the time.  However, the dot-walked field must be present on the form to get the value. The original poster didn't specify if the dot-walked field was present on the form or not, but I think it was assumed by the responses, and that is why the answer is correct.