Building a Portal to IT in Colorado
May 4, 2012, 1:09 pm - James Farrer
Yesterday I presented information about how we've built a Portal to IT at BYU using ServiceNow at the Colorado Local User Group. It was similar to what I presented last year at the ServiceNow user conference, Knowledge11, in San Diego. Since the first presentation we did a major overhaul of our public facing site including a new menu system and many updates that address user feedback we've received. From what I can tell, both the website and the presentation have been fairly well received.
If you're interested in learning more about our CMS site and Service Catalog or if you missed the presentation it can be found here:
Building a Portal to IT (~6 MB PDF)
If you've got feedback, questions, or especially if you're willing to share some ideas about what has or has not worked for you, let me know. I'm also hoping to meet up with folks at the upcoming Knowledge12 conference to share ideas. Let me know if you're interested.
Dropbox and easy photo uploads to my website
April 13, 2012, 11:51 pm - James Farrer
So today I discovered that Dropbox has a Linux client. And that Linux client can be run from the command line. This is important since my servers don't have GUI's installed. This is very important since I've been struggling with easy file upload to my website for quite some time. This is important since I have well over 10,000 photos on my site and the number is steadily growing.
For the most part I've been the primary contributor. And for all practical purposes, the only contributor. I have a custom built site that I use for a number of things, one of which is to learn how to do stuff. As part of this I have built in the ability to do bulk photo uploads via a mapped network drive. This is great if you're on my home network where you can map the drive. If not, well, it starts to get messy real quick. You can upload photos one at a time, but that's just painful unless you only have one. And this is rarely the case for me or other family members that want to contribute.
So here's the nitty gritty of the idea I had. I can set up a shared folder in Dropbox with those people who want to do bulk photo uploads to my site. I put the Dropbox client on the server, which other than having to find a custom init script to keep the daemon running, was pretty simple. Viola! now my Dropbox files are on the server, including this shared folder for uploads.
The next step was to update my bulk photo import functionality in my website to look at the dropbox folder. I went the extra step to make it look at both the old folder and the new one to keep the existing functionality intact and then I had it. I was able to use pretty much the same code I already had and it's working pretty slick. The biggest snag was that I had to set a few folder permissions to make sure the server could get to what I wanted. Otherwise pretty simple
One of the next steps, now that Dropbox also has automatic photo upload from my phone, will be to set up a scheduled job that will monitor the Camera Uploads folder and automatically import them. Then I'll have roughly my own version of what Google+ does, which is super convenient. That will be a future step since I currently don't have the option for having private photos on my site and I don't want the pictures to be automatically public. Now that I have the hard part solved with Dropbox, that's just a matter of time before I can do all sorts of things like that.
If you haven't signed up for Dropbox yet and want to, you can by clicking on this link: http://db.tt/681mdFko. By doing so you'll give me some extra space for free and we both win.
RESTful JSON Web Services in ServiceNow - Part 2, How To
February 25, 2012, 10:57 am - James Farrer
This should explain the basic pieces needed to write a JSON web service in ServiceNow. The background leading up to this is contained in Part 1.
Processors
Processors in ServiceNow are an as yet relatively undocumented feature that is used in the system to provide different formats for using the data in tables. For example, for a JSON version of the data in a table you can tack on JSON as a parameter in the URL and it will use this Processor:

It takes the parameter as indicated in the Parameters field and passes it into a Script Include to do the heavy lifting.
The g_request, g_response, g_target, and g_processor variables that are passed in allow for obtaining input parameters to the Processor and assembling and outputing the response. A few options I used in my JSON web service are g_request.getParameter(), g_response.setContentType() and g_processor.writeOutput().
In order to set up the Processor the Type must be set to "script" and instead of using the Parameters field, fill in the Path. This will be the name in the URL, so if your Path has "super_cool_service" then you will access the Processor by going to "https://yourinstance.service-now.com/super_cool_service.do".
The rest of the magic happens in the script. You are most likely going to want parameters passed in. For what I did these were passed in the URL as standard GET parameters and I retrieved them with
g_request.getParameter("parameter_name")
In my case I needed to do an aggregate query on Incident data and return the summarized results. So I took the parameters, sanitized them, and used them to build the query.
Then it looped through the results and built a javascipt object with the data we wanted to send back.
There are a couple pieces of code that make it possible to return the results as a JSON web service. ServiceNow has a JSON class that allows translating to and from a JSON formatted string to a Javascript Object. I have used this in other places to parse JSON data from web services and here am doing the reverse to generate the JSON string from the object that was created.
g_response.setContentType("application/json");
var response = new JSON();
g_processor.writeOutput(response.encode(response_object));
The first line sets the HTTP content type so clients understand what format the data is coming back in. When I added this my JSON formatter browser plugin starting recognizing the content as JSON and formatting it in a bit more readable manner. The next line instantiates the JSON interpretter that is used in the last line to encode the object that was assembled. The last line also sends the resulting string back to the browser.
That's the meat of it. One of the things I did to make the service a little easier to consume was to make it self-documenting. That means that if you don't pass in the required parameters it returns an error message as well as the instructions for what inputs it expects. I've seen this in other services and have built on the idea and here's the result:

In my case I expect additional functionality to be added to this service so I set up the Operations array in the response to allow for more report options. This is the response if the service is called directly with no parameters.
Another point of note, we put the actual querying into a Script Include to allow for reuse. For example if we later need to make an HTML version of the report we can simply create a UI Page that calls the Script Include and format the returned object.
I'd be interested to hear any feedback on improvements or other options. This is advanced ground with little documentation but it promises to be incredibly flexible and useful.
RESTful JSON Web Services in ServiceNow - Part 1, The Background
February 25, 2012, 10:14 am - James Farrer
In my work at BYU I work on the Office of IT's website and internal tools that are powered by ServiceNow. This has been a good solution for us giving us more flexibility out of a purchased solution than I have ever seen. At BYU we are trying to build out a Service Oriented Architecture (SOA) and have been creating many web services to enable systems to talk to each other.
ServiceNow has been very powerful in enabling us to fully participate in SOA. We are one of the largest consumers of various web services on-campus. ServiceNow's native web services have made it possible for others to consume information from us as well. This is a win-win situation.
In the Office of IT we started with a preference for SOAP web services and have since migrated to RESTful JSON web services since they have generally turned out to be simpler to set up, understand, and consume. They are also significantly less verbose (if you've may it this far into this article then I'm guessing this isn't news to you).
Generally any set of data or table in ServiceNow is automatically accessible via several forms of web services. This has been great, but there are some cases where we need to do a little more heavy lifting than just basic querying, inserting, and updating. This is where Scripted Web Services come in. We've made a couple of these. The most notable of which provides others the ability to tie into an order process in the Service Catalog.
This has been a good tool, it is for SOAP web services and lets you easily take inputs, script the heavy lifting, and then return the outputs, but it was not designed to return multiple records and isn't our preferred way of building web services.
Then a few days ago I ran into a post by John Anderson, a ServiceNow integration specialist, on his blog about how to launch a scheduled job from a URL. That sounded an awful lot like a REST web service to me.
He used a Processor to do the job. These are essentially undocumented and advanced parts of ServiceNow. I had run into them a little bit at a ServiceNow conference but hadn't explored it much. When I saw John's post the lights started going on.
It was convenient that yesterday we also had a request for a web service to return some data that can't be easily obtained with the default web services.
One of my student employees and I took the head start John gave us and spent a combined 12 hours yesterday to learn about, build, document, and turn over to the users for validation a RESTful JSON web service. I'd say that was a successful day.
Now that I've written a whole bunch of history I think I'll split the how to into a separate post, Part 2.
SOPA and PIPA? What are they thinking!?!?!
January 18, 2012, 7:59 pm - James Farrer
If you have paid attention to the news over the last few days or if you have visited any one of the thousands of popular websites today including Google, Wikipedia, and many others, then you are probably at least vaguely familiar with the Stop Online Piracy Act (SOPA) and the Protect Intellectual Property Act (PIPA). These are similar bills that are being discussed in the House and Senate.
When I first heard about it I didn't think too much of it, but as I have discovered more details I have been very surprised that something with so much potential to limit free speech, innovation, and progress in our country could make it into the legislative process at all, let alone being up for a vote in the next few days. I've read quite a bit on it and am not surprised at all to see so many sites and people protesting this legislation. While am not opposed to protecting copyrighted works, this goes too far.
Here is probably the best analysis I've seen today of what the bills propose and what some of the ramifications for world and Internet are. Please read:
http://mashable.com/2012/01/17/sopa-dangerous-opinion/
Just the fact that I'm posting this on a website that I own and allow comments on this post would put me at risk of losing my site and a whole lot more (especially since I could be held liable for attorney's and other fees).
As near as I can tell, the technology industry is one of the fastest growing industries right now and I know of a large number of job openings in this industry. These bills, if passed, have significant potential to bypass due process of the law and stifle growth, innovation, and progress essentially reversing the growth trend if not completely destroying a significant part of the technology industry. If you think about it most companies need a website any more just to survive making the effects far more reaching than just the technology industry.
For a government that seems pretty focused on creating jobs in a slow economy this is definitely going the wrong direction.
Just the financial implications of having to censor content on websites the way these bills indicate would put most small technology startups out of business before they even got started.
The impact alone on technology businesses would likely negate any possible benefit that the music and film industry could hope to gain from something like this.
To sum things up: SOPA/PIPA = Bad Idea! Anyone that supports this has definitely lost my vote because they are clearly indicating that they are out of touch with the world and are not willing to think through the very things they are signing their name to.
Waiting for something to load?
December 1, 2011, 4:15 pm - James Farrer
Try as I may, there always ends up being some place where users on my websites have to sit and wait for something to load or happen. A while back a few co-workers and I came up with a bit of code to help with the situation. It's a little bit of javascript that has made a few people smile and hopefully will make plenty more smile.
Enjoy!
var randomLoadingMessage = function() {
var lines = new Array(
"Locating the required gigapixels to render...",
"Spinning up the hamster...",
"Shoveling coal into the server...",
"Are we there yet?",
"Hang on a sec, I know your data is here somewhere",
"Searching for Answer to Life, the Universe, and Everything",
"Warming up the processors...",
"Re-calibrating the internet...",
"Working... So, how are you?",
"Please count to 100...",
"Doing something useful...",
"Are you ready?",
"Prepare for awesomeness.",
"Yes there really are magic elves with an abacus working frantically in here.",
"Don't panic...",
"Deterministically simulating the future.",
"Searching through billions of bits to find what you're looking for.",
"So, do you come here often?",
"Recalculating PI...",
"Preparing for hyperspace jump",
"Loading: one Mississippi Loading: two Mississippi Loading: three Mississippi",
"Waiting for magic to happen...",
"Please wait while the punch tape loads...",
"The hamster is running as fast as it can, hold on a second...",
"Searching for answers...",
"Looking for exact change...",
"Giving it all of got...",
"It's around here somewhere... ",
"Loading screen... If you can see this I'm still working on your request.",
"Waiting for something in the server.",
"This page brought to you by the Letter Q...",
"Firing up the hyperspace quantum overdrive...",
"Let me think about this...",
"Gotcha, boss! Going right at it!",
"Going the distance...",
"Searching for dragons...",
"Reassembling atoms...",
"Winding up the rubber band...",
"We're working on making this page load faster",
"I spy something green...",
"Configuring the flux capacitor"
);
return lines[Math.round(Math.random()*(lines.length-1))];
}
Daylight Savings Time - Where's the savings?
November 17, 2011, 10:44 pm - James Farrer
As we are getting over the semi-annual schedule tweaking adjustment of Daylight Savings Time I have to stop and think, "If Daylight Savings Time is so great, where's the savings?" I don't in any way profess to be an expert on why Daylight Savings Time came to be or really anything else about it. I do know that with a little bit of logical reasoning I have some serious questions about its value.
As it has been explained to me, some of the chief benefits of Daylight Savings Time have to do with the use of daylight during normal daytime hours, and the amount of energy consumed. I've heard the argument applied to farmers, fossil fuels, electricity consumption, etc. But nothing that I've heard gives me any confidence that the benefit is worth the cost. That's the direct cost., of the fuel or electricity or whatever we're trying to save. I've never heard of anybody actually trying to look at some of the indirect costs associated with this arbitrary adjustments of billions of clocks around the world.
According to the California Energy Commission (http://www.energy.ca.gov/daylightsaving.html) there is a qualified possibility of a 1% energy savings by adjusting to Daylight Savings Time, but they also talk about how there are studies that have found the end difference to be almost negligable. It varies by location, but most generally the recent arguments for Daylight Savings Time use and adjustments are based around people needing lights and using TV's, computers, and other small appliances.
I don't know if the energy savings have actually amounted to anything substantial. Based on the conflicting reports and arguments I see significant room for questioning those savings. In any case, there are some costs that should not be overlooked when considering Daylight Savings Time. These are time and cost of accomodating for the shifting answer to the question "What time is it?"
How much time did you spend thinking about when Daylight Savings Time takes effect? How many clocks did you have to set? Did you sleep poorly due to the time change? Did you forget to change your clocks and miss something? Or did you show up too early and had to sit around and just wait? All of these amount to extra time that has to be spent to make sure we are on time. And we do this twice a year. Think about it, 20 minutes for the first question, 20 minutes for the second, an hour of spaced out time at work due to the messed up sleep schedule, and a few extra minutes for the occasional missed meeting. I would place a conservative guess for this at 3 hours a year, per person. Assuming half the world really just doesn't care about the time that much we've got 3.5 billion x 3 hours coming to a total of 10,500,000,000 lost man hours. 10.5 Billion!!! Even at minimum wage that's a lot of "time is money" kind of cost.
Now for another side of indirect cost. The cost to make everything work across all the time zones, all the states, all the countries, where some use Daylight Savings Time and some don't, and many happen at different times of the year.
I work in IT and I know first hand that this can be a very frustrating and time consuming activity to account for in computers. This is a relatively new side of the challenge. When it all got started we just needed to worry about what time the train was going to arrive. Now we have to know what time the train, plane, bus, car, letter, email, text message, alarm, financial transaction, change to your phone bill, and change to just about anything stored on a computer. A lot of organizations do a lot of activities and reporting based on time. If the computer (at any of about a hundred levels) calculates the time incorrectly there is a very real effect.
So to get all these computer systems to work properly a lot of organizations have to pay a lot of programmers to spend a lot of time and headache making sure that the dates match and that we really know how many hours its been since that starting date and time. I have personally spent a number of days of my life purely trying to accommodate for these arbitrary changes to the time. And every computer, every computer program, every website, all need to be written in such a way as to make it all just work. I assure you this is not a trivial task. This is a very real cost to businesses. In an good economy this can be painful, in a bad economy this cost could be the difference between staying in business and shutting the doors.
For all the potential savings that Daylight Savings Time is supposed to give us, I think the costs, direct or otherwise, far outweigh the benefit. I would propose that we eliminate Daylight Savings Time completely. If the energy costs are that big of a deal then let's change the clocks once and be done with it.
And hey, given the current economic challenges, doing away with Daylight Savings Time right now would mean extra jobs to help accommodate for this final change in the short term. In the long term both business and government would be able to use all that extra time and money to invest in other more productive endeavors.
Then we can all sleep that much better two nights out of every year.
TractorLandscaping.com
September 28, 2011, 9:28 pm - James Farrer
My father-in-law just started a new business doing property maintenance and landscaping. He bought a nice big tractor and is already rolling. As part of that he asked me to build him a website. I've played with a number of different setups and figured Wordpress would be a good option for this one. I set it up and things look to be running pretty good. We're still updating some of the content but for a few days work I think it turned out pretty good.
Check it out: http://www.tractorlandscaping.com
New Server, sort of...
September 13, 2011, 10:41 pm - James Farrer
My old server was running out of space and in desperate need of some work so over the last few weeks I've been working on installing a new server and getting things migrated over to it. I believe I've got just about everything set up and working as I want it now. While on the public side of things there's not much difference, on the back end it's fairly refreshing to have a good clean set-up. Over time things just tend to get cluttered up so this was a nice chance to de-clutter.
Now that that's done it's on to another project I've been thinking about for a while.
The Flavor is Here!
July 22, 2011, 11:21 pm - James Farrer
I finally got some color and life breathed into the new layout. I got some ideas from my wife and daughter which helped get things rolling. It's always a work in progress but I think it's a good improvement over anything I've done before. I think I still want to make some changes to the header section to make it a little less drab but I'll have to think on that for a bit.
As I was working through the process I discovered the ability to add multiple background images (comma separated in the CSS tags) that apparently is new in CSS3.
I was also introduced to the drop shadows as done in CSS and was surprised at how easy it was and how good it looked. I did run into a challenge with the shadow overlapping the other content blocks. It was fairly confusing. I believe most of it has to do with the way I am using floats to do the layout. Floating the sections is certainly not the only way to do it but it made it so when there is the third column in the smaller layout I can drop it back to the left under the other menu. The example that I got the base for the layouts from used a mix of floats and fixed positioning and I ended up moving more entirely to floats for the main sections.
I tried using z-index to force the order on the content boxes but at most I could affect one section, and never the right ones in the right order. I ended up just avoiding it for now by making the shadow fit into the margin width so it doesn't overlap the content. I had to adjust some of the margins to get things to fit in the right places. This was probably a good thing anyways to make it more consistent.
Here's an example of the narrow 2-column layout. Click to see the old look and feel and the new at various sizes.
