Securing .list And .do Pages Via ACLs

Within ServiceNow, anyone can go to any table by manipulating the URL or via the navigation menu.

I.E, if you want to go to the incident table, even if you haven’t access to the incident module, you can just:

  1. go directly via the url: https://sn-instance.com/incident_list.do or https://sn-instance.com/incident.do
  2. in the navigation menu search bar, type incident.list or incident.do

Having ACLs in place makes sure that the actions that you don’t want to happen don’t happen (create, write, read, delete). However, what if you just want to stop navigating to that URL in the first place?

You can stop users getting to the page via the navigation menu by editing the ‘NavFilterExtension’ UI Script (it has very good comments in there and easy to edit to do what you want).

I accidentally stumbled across a neater solution, again using ACLs.
Continue reading

Accessing Tomcat Logs In Real Time

Update: Just to add that these Tomcat logs are node specific. So if you want to watch another user’s transactions, you need to  be on the same node as that user. To switch nodes, you can use my Chrome Extension that’s on the store. More info is here

When trying to debug an issue, you add alert statements, log statements and info messages to a script attempting to understand what’s going wrong.

Often you can find the root cause relatively quickly. But other times, no matter how hard you look, something seems to be failing at a lower level. This is where the Tomcat server logs come in handy.

Accessing these usually requires downloading the log file and tracking down the exact time to find the issue.

The easier option is to watch the logs being written in real time with this simple Out of the Box UI Page and loading up whichever action your performing in one window, and watching the logs on the other window side by side: Continue reading

Generate Schema Definition

Updated the code because of a bug
At one of my clients, we were integrating with a number of systems. One in particular had asked for a schema definition of the tables they were reading from and writing to.

So I decided to write a script to provide a JSON output of the schema. As it’s going through the columns of the starting table, if it finds a reference field, it’ll do the columns of that table, and if it finds a reference field there it will do the same again.

It does this up to 5 levels deep. If it finds a self referencing reference field (such as manager on the sys_user table, it’ll just put in ‘Recursive Reference’).

ServiceNow will output it in one long string, but if you go to a site like Dirty Markup and paste the details, it’ll format it nicely for you.

Continue reading

Intercepting Record Access

For years I’ve been working with ServiceNow and every time, one thing that always got to me that I never understood how it was accomplished was when viewing a sc_request record in self service view, it always re-directed to the order summary UI page.

order_summary

I just couldn’t figure it out and just assumed it was some hard-coded logic hidden away from us… until now! (yes, I’m a little excited about this…)

Continue reading

Quick Access To Record From List View

When using a reference field, you can hover over the reference icon to view the referenced record as a popover. A few people already know, if you don’t want the popup to disappear as soon as you move your mouse, just pressing the shift key will keep it in place allowing you to scroll.

That one’s been doing the round for a while now, but today a colleague showed me another cool thing with the shift key in Fuji.

From a list view, you can hover over the (i) icon on the row to view the full page form. Holding shift before hovering over the icon will actually render the page fully editable, UI actions and all! Saves a click into the record to update it.

Screen Shot 2015-08-11 at 12.55.43

Tip For Creating Complex Before Query Business Rules

Before query business rules are great! I absolutely love them and use them all the time.

Sometimes though, I do find myself getting into a bit of a twist with the logic in the code.

Before I show you what I do now to overcome it, i’ll quickly explain what a before query business rule is. Put simply, it’s exactly as the name implies. It’s a business rule that runs before querying the database. More specifically, it can add additional query parameters to the search automatically and invisibly to the user.

For example, if a user wants to view all users, they can go to the sys_user table with no query parameters.

The system will essentially do the following code to bring back the results:

var current = new GlideRecord('sys_user');
current.query();

Now, if you want to only allow users to view active users, this is where a before query business rule comes into play. If I gave you the above script and asked you to only return active users, you would amend the code to be:

var current = new GlideRecord('sys_user');
current.addActiveQuery();
current.query();

A before query business rule is no different. You’d create the business rule and add the line current.addActiveQuery() to the body and that’s it (side note, a before query business rule is one where the ‘when’ field is set as before and the ‘query checkbox is ticked’). So essentially, the before query business rule is made to add additional query conditions to the query GlideRecord. The above example can be seen in the business rule called ‘user query’ out of the box on the sys_user table.

Now that’s out of the way, adding a simple parameter like above to a query is simple, but when you have 5/6 different parameters and different conditions for each one, and different values, things gets a little/lot more complicated.

The way I get around that is simple.
Continue reading

Securing The Activity Formatter (Or Any Formatter For That Matter)

The activity formatter on a form is a great part of ServiceNow. As long as it’s added to the form, and the table is audited, you can get a quick glance of the most important updates.

However, my only issue with it (and it’s my issue with all formatters), is that you can’t apply an ACL to it. For some users, I don’t want them to see it at all, but I don’t want to have to create a custom view just to hide it.

What I did therefore was found a way to apply ACLs to the formatter. This little trick can be used on all formatters.

Continue reading