Autopopulate the fields(country, Region) in catalog item as user login

Sharada N S
Tera Contributor

Hi everyone,

In catalog item for logged- in user country and region needs to be auto populated. we have a variable set were we get values of  Requested for(user name from sys_user table) and location(deatils from cmn_loaction table) which is auto populated. In the same way need a onload client script to Auto Populate 'Country' and 'Region'(Single Line text fields) for logged in user (using the location field present in variable set).

BanashriBM1_0-1711360649865.png

Thanks

 

 

 

7 REPLIES 7

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Sharada N S ,

 

If you are on the latest version of servicenow them you can make use of autopopulate table from variable dictonary. If not then you have to make use of client script to auto populate.

SohailKhilji_0-1711361261645.png

 

I hope this helps....

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi Thanks for ur reply 
I need a client script

 

Server side be like :

 

var grr = new GlideRecord('sys_user');
grr.addQuery('sys_id' <param value>);
grr.query();
if(grr.next()){

var obj = {};

ojb.country = grr.country.getDisplayValue();
obj.region = grr.region.getDisplayValue();

}

return obj;

 

On client script you can parse the json object and set the value...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hello @Sharada N S can you please tell us in which table region field is available?