I have to get User's location state value.

niveditakumari
Mega Sage

Hi, 

 

I have to get User's location state value. 

I have User's table and from User's table I have to get User's location and then state value in script. 

Below is attached screenshot : 

niveditakumari_0-1696543121111.png

 

In above screenshot I'm getting current logged in User and then I'm querying that in hr profile table and then I'm retrieving entCode and empClass from HR profile table and if that condition satisfy then after that I'm setting groupingName. 

In same way I need to query User's location and get state field value and if state is AB then I need to set groupingName. 

 

Can anyone please help me to achieve that. 

 

Regards, 

Nivedita

 

 

 

23 REPLIES 23

Mike_R
Kilo Patron
Kilo Patron

You can use

var location = gs.getUser().getLocation();

 

 

Hi @Mike_R

 

Thank you for your reply. 

I have to query if Current user's location state is AB. 

ex - You are logged in currently and if your's location state is AB then set groupingName ABC. 

How I can check that. 

Can you please help me with script. 

 

Regards, 

Nivedita

 

 

 

var userLocation = gs.getUser().getRecord().getValue('location') ;
var location = new GlideRecord('cmn_location');
location.get(userLocation);
var state = location.state;
if(state == 'AB'){
groupingName = 'ABC';
}

 

 

Hi @Mike_R

 

This code is not working. 

I'm getting error.

Please find attached screenshot : 

niveditakumari_0-1696940404549.png

 

Please correct me to achieve that. 

 

Regards, 

Nivedita