john_roberts
Mega Guru

I was just reviewing all the cool things I do in Quicksilver so I could record a video highlight reel (hopefully posted in the near future). Even though Quicksilver is the bomb I just thought of an even better solution for one of my shortcuts.

Disclaimer: I work on a Mac so that's all I usually spend time automating these days (sorry Windows friends).

I frequently get emails or chat messages with a task number to review but the sender didn't include a link to our instance. I wanted a way to select a task number in any application and get to the task record in as few keystokes/clicks as possible.
My latest solution for this includes OS X Services, Automator, AppleScript, and a keyboard shortcut. If you haven't played with Automator yet, take the time to learn the basics, it's well worth the time you'll save.
Here's the video tutorial and demonstration. Script and details also listed below.


Details:
First we need to create an OS X service menu. Launch the Automator application. We need some scripting to help figure out which table we should I after based on the task prefix. Locate and drag the AppleScript action from the left pane to the right working pane. Copy the following script to meet your needs. It's pretty self explanatory. You'll need to at least modify the instance server.



on run {input, parameters}
--get input as text
set task to (item 1 of input) as text

--determine url from prefix
if task starts with "PRB" then
return "https://demojlr.service-now.com/problem.do?sysparm_query=number=" & task
-- optional url example for full ServiceNow frames
--https://demojlr.service-now.com/nav_to.do?uri=problem.do&sysparm_query=number=PRB0000010
else if task starts with "INC" then
return "https://demojlr.service-now.com/incident.do?sysparm_query=number=" & task
else if task starts with "CHG" then
return "https://demojlr.service-now.com/change_request.do?sysparm_query=number=" & task
end if

--send url to display webpages action
return input
end run


Ensure the options above the script are set to accept text input from any application. The text you have selected before calling the service will be passed to the script as the input parameter.The script returns a URL to the correct table with a query for the task number. You could also load a list for partial matches is you wanted to search for something other than a number, say text in a short description. Now let's add the display webpages action. Drag it to below the script block. Actions pass output to the next action, so our script is going to output a URL and tell the display webpages action what to load.
That's all the heavy lifting we need. Go ahead and save it with some useful name like "Find task in MyInstance".

Now when you select a task number you can go to the services menu and select it. But that's way to much mousing around for a shortcut junky like me. Let's add a keyboard shortcut to our bag of keyboard ninja tricks. Open Keyboard Preferences (hint, you'd get there faster if you used Quicksilver). Select the keyboard shortcut tab, then Services and locate your new service. Click the far right of the service name and assign a shortcut (be sure the service is still checked since it may uncheck when you click to add shortcut). Now you're ready to go select a task number text somewhere and try your new shortcut.
Enjoy the few extra seconds you gain everytime you lookup a task without a link.

Already using Automator? Or did this trigger new ideas? Let's hear what you're thinking.

2 Comments