Autofill User location value into a form

Peter Williams
Kilo Sage

Good Day, 

i am trying to figure out a Client script for onLoad to have the user who is opening the form, their Location to be automatically added to the Location on the form

 

Ex.

PeterWilliams_0-1675882259723.png

 

so who ever logs into the form, their Office location (cmn_location) will be automatcally filled in this field. (u_office_orgin_location)

 

Both the Sys_user location and this Office location is a reference field that is pulling from the same table cmn_location

 

any help is appricated

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Peter Williams 

So logged in user's location should be auto-populated in the variable/field?

you can use default value in that field

javascript: gs.getUser().getLocation();

What did you try so far and what didn't work? What did you debug?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Peter Williams 

So logged in user's location should be auto-populated in the variable/field?

you can use default value in that field

javascript: gs.getUser().getLocation();

What did you try so far and what didn't work? What did you debug?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

i tried that and its working

thank you