I need to fetch the location of the requester from the Incident table.

Leticiad
Tera Contributor

I need to fetch the location of the requester from the Incident table. I created the location field in the Incident table and would like to know if I can do this using the default value in the dictionary.

1 ACCEPTED SOLUTION

Bhavya11
Kilo Patron

Hi @Leticiad ,

 

you can do with dot walking the User location field to avoid script like below

as you have Requested for as reference field to User 

search your field click on '+' icon

Bhavya11_0-1734588495275.png

 

then it will list all field of the User fields then find the location field 

Bhavya11_1-1734588557848.png

then save the form

Bhavya11_2-1734588590067.png

 

if you select the Requested for then automatically location populates if user has location defined

for example

Bhavya11_3-1734588645138.png

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Thanks,

BK

  

 

 

 

View solution in original post

4 REPLIES 4

Bhavya11
Kilo Patron

Hi @Leticiad ,

 

you can do with dot walking the User location field to avoid script like below

as you have Requested for as reference field to User 

search your field click on '+' icon

Bhavya11_0-1734588495275.png

 

then it will list all field of the User fields then find the location field 

Bhavya11_1-1734588557848.png

then save the form

Bhavya11_2-1734588590067.png

 

if you select the Requested for then automatically location populates if user has location defined

for example

Bhavya11_3-1734588645138.png

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Thanks,

BK

  

 

 

 

Harish Bainsla
Tera Sage
Tera Sage

Hi @Leticiad you can do without script as well as @Bhavya11  mentioned and if you want to do with script  I try on my PDI based on caller I do its working fine for script check below code. write onchange client script

var getLocation=g_form.getReference('caller_id', LocationData);
}
 function LocationData(getLocation) { // reference is passed into callback as first arguments
 g_form.setValue("location",getLocation.location);
}
if my answer helps you mark helpful and accept solution

Runjay Patel
Giga Sage

Hi @Leticiad ,

 

Dot walking change the actual value of requestor if user select other than default value mentioned on user profile. If your intention is to only show the requestor's location then do dot walking like below. Make this filed read only using ui policy.

RunjayPatel_0-1734589904948.png

 

And if you want to store as incident value then create new filed is the option and to set the value use below script in onchange client script 

 

var loc=g_form.getReference('caller_id', LocName);
}
 function LocName(loc) { 
 g_form.setValue("location",loc.location);
}

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Hi @Leticiad ,

Thanks for marking my solution helpful, now community enable multi acceptance feature so you accept multiple.