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

Hi @Ankur Bawiskar

 

This is not working. 

Please find attached screenshot : 

niveditakumari_0-1696947398589.png

 

I have added above code but it is not working. 

Please help me to achieve that. 

 

Regards, 

Nivedita

 

 

@niveditakumari 

did you check what came in the state variable for logged in user?

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

Hi @Ankur Bawiskar

 

I have added log statement to get state value.

Please find attached screenshot : 

niveditakumari_0-1697050667853.png

 

It is not printing state value. 

Please correct me to achieve that. 

 

Regards, 

Nivedita

 

 

@niveditakumari 

are you sure the state field name is correct?

the logged in user has state populated in location?

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

Hi @Ankur Bawiskar

 

Yes field name is correct. 

Please see attached screenshot : 

 

niveditakumari_1-1697111726147.png 

 

niveditakumari_2-1697111753904.png

 

niveditakumari_3-1697111770505.png

 

It is showing state as N/A but in log it should show log statement state is N/A. 

niveditakumari_4-1697112231761.png  

 

Please correct me to achieve that. 

 

Regards, 

Nivedita