Skip to content

Commit f9a60bc

Browse files
authored
Feature/bookmarklet (#2084)
* Create readme.md * Create listquery.html * Update readme.md * Update readme.md
1 parent fa1fccd commit f9a60bc

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<A HREF="javascript:top.open('now/nav/ui/classic/params/target/sc_request_list.do%3Fsysparm_query%3Du_addressLIKEmain%2520st');">RITM Addresses</A>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Sometimes you can't include the condition you want in a graphical list filter, but a (GlideRecord) encoded query is valid.
2+
3+
An Example:
4+
On my sc_request table I have created a field with the type Name-Value Pairs to store address information that will accommodate varying global formats (dynamic content and number of fields). This field type allows you to add as many pairs as needed to each record.
5+
The value of this field is stored in JSON, containing the Name and Value of each pair added:
6+
{"Street":"123 Main St","City":"MyCity","State":"MyState","Zip":"90210"}
7+
8+
Business Case:
9+
If I need to find all of the Request records that contain a certain City name, Zip Code, Street name or address etc., I cannot do so in a list view of the Request table, as the only conditions available are 'is', 'is not', or 'is anything':
10+
There are probably other useful conditions missing for various field types.
11+
12+
In a script, I can get the records I'm looking for via GlideRecord using an encoded query. As a simple example, let's say I want to retrieve all of the records that contain 'Main St':
13+
14+
'u_addressLIKEmain st'
15+
16+
The Workaround:
17+
By adding a sysparm_query to the URL, the list will be filtered appropriately. The above encoded query resolves like this when added to the end of a URL:
18+
https://instancename.service-now.com/now/nav/ui/classic/params/target/sc_request_list.do%3Fsysparm_query%3Du_addressLIKEmain%2520st
19+
20+
Where sc_rquest is the table name,
21+
u_address is the field name to query on,
22+
and the rest is the encoded query
23+
24+
When doing this, you will see the correct filter reflected in the breadcrumb, but here is the best part - now when you expand the filter via the funnel icon, 'contains' is a valid operator, so you can change the text/value to whatever else you are looking for!
25+
While this is a simple example, passing in a complex encoded query with ANDs and ORs will also work to filter the records and update the filter where building the filter manually is limited.
26+
27+
This bookmarklet is formatted to open a new tab when logged into an instance.

0 commit comments

Comments
 (0)