Identifying the Client or Session IP Address

As a Service-now administrator or consultant, you may run into situations where it is necessary to identify the IP address of a user session before performing some action. These situations are almost always security-related. For example, you may want to restrict the ‘Delete’ operation for Change request tickets to users at a specific location, or you may want to show a particular UI action button to users whose sessions originate from a particular IP address.

I haven’t seen this type of request very often, but it is pretty simple to get this type of information in Service-now. This post shows you how.

To get the IP address of a user session you simply have to use the ‘getClientIP()’ method to pull the IP address from the current user’s session object.

//Return the current user session's IP address in string format

Here’s another example that shows how you could use this in a security ACL script.

//Only allow permission for sessions with '' IP address
var answer = false;
if(gs.getSession().getClientIP().toString() == ''){
   answer = true;

This information is also available via the user transaction log. You can see the full transaction log by navigating to ‘System Logs -> Transactions (All User) or by navigating to ‘User Administration -> Logged in Users’ and opening one of the user session records. This method is sometimes more useful since the transactions are grouped by user session in a related list at the bottom of the transaction record.

User Transaction Log Entry

Date Posted:

February 28, 2011

Share This:


  1. Matt Gaide February 28, 2011 at 10:30 am

    Well done, once again!

  2. Sean Grison March 3, 2011 at 12:55 am


  3. Scott Eberly March 27, 2012 at 8:18 am

    Is there anything else you can grab from getSession() besides the IP?


    • Mark Stanger March 27, 2012 at 3:26 pm

      ‘getSession()’ is just the glide session object. There’s a lot of additional information that you can get from it (user, impersonation, language, etc.). The IP piece is really the only useful piece that isn’t documented anywhere else (in my opinion). I think ServiceNow could do a better job of documenting these in one place though.

      • Scott July 10, 2013 at 12:41 am

        Agreed. There are little hints about all sorts of objects scattered throughout their Wiki, but there are very few ‘API’ documents around. Even in the API documentation sections.

        Any pointers to where we can find out more about the glide session object?

        • Mark Stanger July 10, 2013 at 7:04 am

          Unfortunately, there’s nowhere but the ServiceNow wiki that I’m aware of. It’s interesting to me that ‘GlideSession’ on the wiki just points you to ‘GlideSystem’, which is completely different. The best course of action is to comment on the wiki and ask for more information I think.

          • Scott July 10, 2013 at 7:12 pm

            Thanks, appreciate the response Mark. I’ve just got a community account today so I can do exactly that :)

  4. Jason March 18, 2013 at 10:29 am

    You should note that this only returns the external facing IP address and not those behind the clients router. As such there is no way (as far an I know) to get hold of the internal IP address of an end users machine – for say remote support purposes.

Comments are closed.




Fresh Content
Direct to Your Inbox

Just add your email and hit subscribe to stay informed.