I have to get User's location state value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 03:06 PM
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 :
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:28 AM
Hi @Ankur Bawiskar,
I have to check
if User's location.state == 'AB'
then groupingName = 'Alberto'
else if location.state == 'ON'
then groupingName = 'Ontario'
then what should I add in above code.
Please help me to achieve that.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:30 AM
you want to set groupName as per location.state or as per your existing code where you are checking data for HR profile fields?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:42 AM
My existing code is existing code which is getting logged in user and in hr profile it is getting some data based on that it is setting grouping name and it is working fine.
There is another requirement I'm working on that I have to set grouping name based on logged in User.location.state == ' AB' grouing name 'Alberta'.
Regards,
Nivedita
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:46 AM
I already shared the logic. You just need to use it as per your requirement wherever you want
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:31 AM
something like this
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", gs.getUserID());
gr.query();
if (gr.next()) {
var state = gr.location.state;
if(state == 'AB')
groupingName = 'Alberto';
else if(state == 'ON')
groupingName = 'Ontario';
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader