- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-15-2019 01:19 PM
I found myself repeating common queries over and over in ServiceNow. Often times I would want to open a new tab for this search, as it would be a quick one-off, and didn't want to disturb my other tabs. Lately I've been querying the sys_user table for people by name, so I would middle-click (open in new tab) a bookmark for the sys_user table, or type sys_user.LIST (<-- all caps for new tab). Once that table loaded, I would then go to the search box above the Name column, and type or paste the name I'm looking for.
Do this several hundred times and you'll get pretty quick at it. But then you'll start asking yourself, can't it be quicker? Maybe using the Global Search to query the name? Better hope for an exact match there.....
Enter, JavaScript enabled Chrome Bookmarks. With Chrome you can save a bookmark that executes any JavaScript function you want. And for my needs, it can be done very simply. All you have to do is save a bookmark, then edit it and change the url to "javascript: your_code_here;"
To query the sys_user table, the below snippet will open a prompt for the query term. If you click cancel, nothing will happen. An empty field will just open the sys_user table. But if you enter a term, it will open a new tab and query the sys_user table with what you entered!
javascript: var name=prompt("Name");if(name.toString()!='null'){var url='https://yourinstance.service-now.com/sys_user_list.do';if(name!='')url+='?sysparm_query=nameSTARTSWITH'+name;window.open(url);}
This one will navigate to the Global Search. Very handy to open a ticket number if you have the exact INC, or for any other search. It ignores a Cancel or empty query, as that wouldn't be beneficial.
javascript: var search=prompt("Search");if(search.toString()!='null' && search!=''){var url='https://yourinstance.service-now.com/nav_to.do?uri=text_search_exact_match.do%3Fsysparm_search%3D'+search;window.open(url);}
The possibilities are endless with this. I hope these examples spark your creativity and you can save some mouse-clicks!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Consider using custom search engines for these instead (chrome://settings/searchEngines).
A custom search engine has three parts: a name, a keyword and a URL. When you type the keyword into the omnibar followed by a space or tab, it activates the custom search engine, and whatever you type next will be uri-encoded and inserted into the URL wherever it contains "%s".
So you could make a custom search engine with a keyword of "list" and a URL of
https://yourinstance.service-now.com/%s_list.do?sysparm_filter_only=true
to instantly jump to any ServiceNow list by simply typing, for example, "list sys_property"
This works with javascript bookmarklets as well.
This means you could instead make the url
javascript:(()=>{location.assign('https://support.steelcase.com/'+'%s'.replaceAll(' ','_')+'_list.do?sysparm_filter_only=true')})()
and now you don't have to type out the underscores: "list sys user has role" will work just fine.
I like to prepend all my keywords with a semicolon (";list") in case I want to actually search Google for something like "list of fruits", but starting your search with a space will prevent keywords from triggering (and the space won't be included anyways).