Search

An Independent ServiceNow Blog

Category

Scripting

ServiceNow Admin 101: Observations on Database Views, Part I

Service-Now JavaScript Library Resource

Bringing the Update Set Picker back from the UI14 Gear Menu

Service-Now data pull – python vs perl

AngularJS UI Page Framework

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

Workaround For GlideRecord SetWorkflow (false) Issue

Thanks for sharing Ahmed. Excellent info.
Ahmed wrote: “As part of the GlideRecord API comes the function setWorkflow(false) .

If you’ve never used this before, essentially this function switches off the running of any subsequent business rules or workflows. This is really useful in a number of scenarios, for example when you need to update a lot of records in bulk and do not want emails to be automatically sent out for each one. ”

ServiceNow Gems

As part of the GlideRecord API comes the function setWorkflow(false) .

If you’ve never used this before, essentially this function switches off the running of any subsequent business rules or workflows. This is really useful in a number of scenarios, for example when you need to update a lot of records in bulk and do not want emails to be automatically sent out for each one.

I’ve been recently working on archiving and using the OOB implementation was just too slow for us (OOB was taking approximately 5 minutes to archive one incident and 5 tasks, my custom one now archive 150 incidents, 500 tasks, all audit records, journal records, attachments etc, in less than a minute).

But while doing this, I needed to delete records from one place in ServiceNow and put them somewhere else. I didn’t want it audited that I deleted these records nor did I want…

View original post 711 more words

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

Dealing with XML API – Parsing the SOAP response

Techie Geek

Not gonna really try and show off anything here – but the documentation for XML API is a bit foggy and I want to share this. I tried to use a few common XML API calls that are a bit of a challenge to find out about.

Lets pretend you get a SOAP response and you want to manually iterate through that response envelope that has this structure:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <ns0:Root xmlns:ns0="http://Schemas.SNResponse_RigData">
         <Status>Success</Status>
         <RigData>Whatever</RigData>
      </ns0:Root>
   </s:Body>
</s:Envelope>

Here are a few API calls you will need:

      this.fSoapDoc = new XMLDocument(requestXML);
      var soapBody = this.fSoapDoc.getNode("/Envelope/Body/Root");

      var nodelist = soapBody.getChildNodes();
      for (var i=0; i < nodelist.getLength(); i++) {
          var kidNode = nodelist.item(i);
          if (kidNode.getNodeType() == Packages.org.w3c.dom.Node.ELEMENT_NODE) {
            var fieldName = Packages.com.glide.util.XMLUtil.getNodeNameNS(kidNode);
            var fieldValue = Packages.com.glide.util.XMLUtil.getAllText(kidNode);
            gs.log("FIELD NAME: " + fieldName, "cmaloy");
            gs.log("FIELD VALUE: " + fieldValue, "cmaloy");
          }         
      }

This is going to get the name and value of the Status…

View original post 47 more words

Create a Custom ‘New’ Button on a Related List to Return to the Parent Record After Clicking Save

Create VisualForce Tab to Display Static List View for Standard or Custom Object

Powered by WordPress.com.

Up ↑

%d bloggers like this: