In service portal, how to show current loggedIn user Location and Temperature

Sathwik1
Tera Expert

In service portal, how to show current loggedIn user Location and Temperature 

@Ankur Bawiskar  

8 REPLIES 8

Hi,

I want to show the location name from where the user is loggedIn on the service portal..

can't we use any geo location? or any other way to show this?

You can display User Location, but that data need to be present in your Location or some pther table from where you can query and then display it.

Do you have that data available in some table in your instance?

If yes then you need to update the code as below:

Server:

getUserDetails();

function getUserDetails(){
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next()){
data.Name = gr.name;
data.Location  = gr.getDisplayValue('location');

}
}

HTML:

<div>
<span>{{data.name}}</span>
<span>{{data.Location}}</span>
</div>

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sathwik,

you cannot get the location from where user logged in directly from ServiceNow

you can try to use javascript browser code but you need to play with that

in client side add the code; check this for help

https://stackoverflow.com/questions/35267562/how-to-get-my-current-location-on-my-browser

to get temperature you can use some API call which accepts latitude and longitude

Regards
Ankur

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

@Sathwik 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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