TUESDAY, FEBRUARY 07, 2012

Posts Tagged ‘Scripting’

Much of the behavior of a Service-now instance is controlled by System Properties. System properties are a great way to add options to your system and keep people (including yourself) from having to make modifications to back-end code later on. Business rules, UI actions, and UI pages rely pretty heavily on system properties just for this purpose. If I’ve ever got variable values that should be available system-wide then my first thought is to put that value in a system property that can be changed in the UI and be referenced from multiple places in the future. Chances are you’ve worked with these properties as part of your system setup. It’s always a good idea to be aware of the different properties in the system and what they do. The Service-now.com wiki contains a listing of system properties with their descriptions that you can review.
The purpose of this post is to show the different ways you can access, display, and work with properties in the system UI and in the Service-now scripting environment.

Learn more ...

A

common Graphical Workflow requirement in Service-now is to tell the workflow to wait for some trigger before continuing. The ‘Wait For condition’ activity is available out-of-box and is very simple to configure. Usually when working with Service Requests or Change Requests I am asked how you can set up the workflow to wait for completion of all associated tasks before closing the Request Item or Change Request ticket. This can be easily accomplished by using a script in your ‘Wait For condition’ activity to query for any associated tasks that are still marked as ‘Active’. If the task is marked as ‘Active’ then it hasn’t been closed yet and the workflow should wait for that closure. Here are some sample scripts that I’ve used before to wait for task completion on both Request Items and Change Requests.

Learn more ...

H

ere’s a cool tip that was just sent to me by my friend Jim Coyne. We collaborated to solve a problem that he had in his environment and this post shows the result he came up with. This post shows how you can manipulate records in the email log (sys_email table) when you have a need to change the contents or recipients of an email record. Manipulating the outbound email logs isn’t something that should be relied upon heavily and I would consider it basically a last resort but it can prove very helpful in solving the right type of problem.

The problem in this example was that there were emails being sent from Jim’s Service-now system that contained sensitive information. It was necessary to send this information as part of an integration with a 3rd party system but they didn’t want to retain that information in Service-now to be viewed in logs and in the activity history of task records.

Learn more ...

A

few months ago I wrote about copying change requests using a UI action. While that method works great, it does require you to specify each and every field and value that you want to populate into the new change request. If you’ve got a lot of fields to copy over then you might end up with a pretty big script and a lot of items to copy over. You also need to be aware of any new fields that get added after you create the script and make sure that they get copied if necessary.

The following method works in much the same way, but it copies by performing an insert against the current record (rather than starting from a brand new change record and supplying each value). Because of this, you’re concerned about overriding any of the values (such as start and end dates) that you DON’T want to be copied over from the record you are copying. This method works better if you know you want to copy over all (or the majority) of the field values from a given change.

Learn more ...

I

am really enjoying being here at Knowledge 10 and meeting so many of you who read our posts.  I have been busy in one-on-one sessions hearing requests and helping come up with answers.  One of our readers wanted to know how they would go about downloading all of the attachments on a record as a zip file.  Another reader wanted to know how to send attachments as a zip file via a web service.  I believe this post should help solve both questions.

Learn more ...

This post is written in response to a question I received from a reader about how to handle ad-hoc tasks when you’re using graphical workflow. I’m always open to suggestions on how to improve the site and its content. If you have any ideas, questions, or suggestions for the site just use the ‘Contact‘ link to submit them. Thanks Ruth!

“The requirement is to add an extra task to a set of tasks defined in a graphical workflow once it is running AND have a way of specifying the order AND have the new tasks start automatically when its predecessor completes and start the next on when it completes.

In the days of execution/delivery plans I had done this using a rule which set the new predecessor/successor entries but can anyone advise how to approach it with workflow?”

Learn more ...

A

t some point somebody a lot smarter than me (probably the first person who reads this) will see the title of this article and say “No duh! JavaScript and Java are completely different. What a waste of an article!”. You can actually find quite a bit of information on this topic out on the internet but let’s face it, anybody who isn’t in IT or Development probably doesn’t care anyway.

Since both of these technologies are used in Service-now though, this confusion often presents itself so it is good to be informed.

Learn more ...

Service-now.com has announced the upcoming Winter 2010 release!

–Update:

There’s been an overview Webinar scheduled for the Winter 2010 release.  Here are the details:

You are invited to the Winter 2010 Release Webinar
An overview of the Winter 2010 Release is available through two live Webinars with Jay Berlin, Service-now.com principal architect. The Webinars are scheduled for Thursday, January 14, 2010.

9:00 AM PST (4:00 PM GMT) and 3:00 PM PST (11:00 PM GMT)

Register for the Webinar here!

Learn more ...

This is a great function that you can use to eliminate duplicates from an array in Service-now. It’s just standard JavaScript so it will work in Client Scripts, Business Rules, or pretty much anywhere else you want to put it. The function takes an array as the input parameter and returns an array…minus the duplicate values!

function checkDuplicates(a) {
   //Check all values in the incoming array and eliminate any duplicates
   var r = new Array(); //Create a new array to be returned with unique values
   //Iterate through all values in the array passed to this function
   o:for(var i = 0, n = a.length; i < n; i++){
      //Iterate through any values in the array to be returned
      for(var x = 0, y = r.length; x < y; x++){
         //Compare the current value in the return array with the current value in the incoming array
         if(r[x]==a[i]){
            //If they match, then the incoming array value is a duplicate and should be skipped
            continue o;
         }
      }
      //If the value hasn't already been added to the return array (not a duplicate) then add it
      r[r.length] = a[i];
   }
   //Return the reconstructed array of unique values
   return r;
}

One of the great features of Service-now.com is its CMDB and relational mapping.  You can easily set up relationships between any CIs in the system.  Once the relationships are defined, it becomes very simple to pull up a visual representation of a CI and its dependencies by using Service-now BSM maps.  Using this feature allows an end user to look at that CI and identify what else in the environment is impacted by an outage or a change to that CI.

Learn more ...


Latest Comments

  • Mark Stanger: This functionality doesn’t connect to an FTP server. See this line in the post above…...
  • Mark Stanger: The report page is back-end XML so there’s no way to directly manipulate the behavior of that...
  • Mark Stanger: Due to some ServiceNow limitations, the localhost MID server option had to be removed.
  • Matt Haak: Is it possible to use this with the local Mid Server (mid.server.localhost) It appears from this community...