How To Determine The View A User Is On

Sometimes, you only want to run a script if the user is on a particular view. I’ve had a couple of these requirements (albeit it they are very rare! Usually there are other ways around it). But anyway, if you can’t think of any way around it, a small little script can be used to determine that view:

gs.log(determineView());
function determineView() {
  var myView = '';
  if (gs.getSession().isInteractive()) {
    var map = gs.action.getGlideURI().getMap();
    if (map.get('sysparm_view') != null) {
      myView = map.get('sysparm_view').toString();
    }
  }
  return myView;
}

You can put this script as a script include to be called globally or write it in the script you need it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s