Search

An Independent ServiceNow Blog

Tag

scripting

ServiceNow Admin 101: Observations on Database Views, Part I

GlideAjax and JSON

Thanks Jeff. Handy Tips and work around.

Jeff Benedict

In the last month I have been doing quite a bit of client side JavaScript using jQuery and AngularJS and initially had some challenges working with these frameworks and the ServiceNow GlideAjax object due to only being able to pass string values as a parameter.  For example, below is the example GlideAjax usage from the ServiceNow Wiki site:

var ga = new GlideAjax(‘HelloWorld’);
ga.addParam(‘sysparm_name’,’helloWorld’);
ga.addParam(‘sysparm_user_name’,”Bob”);
ga.getXML(HelloWorldParse);function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute(“answer”);
alert(answer);
}

The limitation for me was the “sysparm_user_name”  parameter for what if I wanted to pass in an Array, Object or a list of records to be updated?  This is especially relevant if you start leveraging AngularJS, for with AngularJS you are going to want to filter, sort and update rows of data with client side JavaScript and therefore need structured data variables for which to manipulate.

The solution for me is JSON and attached is an update set…

View original post 378 more words

Advertisements

How to Use Background Scripts

Great tips for #ServiceNow Admin. Careful with background #scripts.

GarrettNow

What?

Background Scripts are Service-Now’s most direct method to run JavaScript directly against the server. This makes them an excellent way to test out the code intended for use in Script Includes, Scheduled Jobs, and Business Rules. Additionally, this is one of the best ways to cobble together text based reports that are too complicated for the reporting module – I’ve often used Background Scripts to aid in outage post-mortem investigations.

Warning!

While powerful, Background Scripts can be dangerous. If you aren’t careful, you can delete all kinds of important or system-critical records. Even more likely, a poorly written script might run indefinitely, causing system performance issues.

Where?

  1. As an admin, use the lock icon to elevate your privileges to “security_admin”.Elevating PrivilegesElevating Privileges Dialogue
  2. Look in the left-hand navigation for “ -> Background Scripts”, and click away.Finding Background Scripts
  3. You’ll see a large box that you can input your JavaScript into, unfortunately there’s no error…

View original post 238 more words

Powered by WordPress.com.

Up ↑

%d bloggers like this: