THURSDAY, JANUARY 19, 2017

Category: Scripting

Parse URL Parameters in a Client Script

H

ere’s a useful script I’ve used before to grab parameters from a URL in Service-now.com. Simply pass the name of the parameter into the function and it will return the corresponding parameter value.

So if you had a Service-now.com URL that looked like this…
https://demo.service-now.com/incident.do?sys_id=-1&sysparm_query=active=true&sys_myparm=abcde

You could get the value of the ‘sys_myparm’ URL parameter by calling the function below like this…

var myparm = getParmVal('sys_myparm');

Here’s the ‘getParmVal’ function…

Read more ...

Changing the Active Tab Selection in Service-now.com

S

ervice-now.com has a nice tabbed form interface that allows users to save some screen real estate by collapsing all form sections and related lists and presenting them in a tabbed format. Tabbed forms are explained on the Service-now wiki.
This post explains how you can use client scripting to change the active tab selection in a form section or a related list. This might come in handy if you want to make a particular tab of information more visible in different situations. Special thanks to Joseph Bennett for doing the real work figuring this out for me :).

Read more ...

Hide ‘Search Knowledge’ or ‘Suggestion’ Icon in ServiceNow

J

ust a quick post today about something that I end up dealing with on most deployments. The requirement often comes to me as this…

How do I hide this form icon for some users but not others?

This request can apply to different types of icons, but is often asked about the ‘Search Knowledge’ (KB Search) icon or the ‘Suggestion’ icon that shows up in a default ServiceNow installation next to the ‘Short Description’ field. This article shows how you can remove this icon (or any other icon image) selectively using client scripts.

Read more ...

Returning Random Records Using GlideRecord

I

had a request from a client recently to generate a random list of records from a given table (specifically the Configuration Item table). These items would be used as a pool of records for a random audit of the records in that table. I don’t think this will be used all that often but I figured I’d throw it out here so that people could use it if they needed it. Here’s the code…

Read more ...

Change Form View Client Script

Service-now allows administrators a lot of flexibility in defining which elements appear on a particular form or list. The set of fields and related lists that appear are collectively defined as a View. One common configuration task is to somehow limit access to a particular view based on a user role or some information on the record being viewed. Instructions for working in some of these scenarios can be found here…

View Rules
Restricting Form Views by Role

Neither of these methods work if you need to change the view of a form from a client script or a UI action. In order to do that, you can call the ‘switchView’ function as follows…

Read more ...

Latest Comments

  • David: It appears that I can hit sys_properties table with REST. This works, but I haven’t yet discovered the...
  • Mark Stanger: Hey David, It doesn’t surprise me that scoped apps have made this more difficult. I’m not...
  • David: Mark, do you have an example of how to do this in a scoped app? It seems there are many hoops to jump through...
  • Mark Stanger: The only possibility is to create a system property to override this in your application. Check out the...