Converting a Reference Qualifier to an encoded query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 05:31 AM
Hello all,
I am interested in the easiest way to convert a reference qualifier into an encoded query. The basic table that I am trying to query is the cmdb_ci table which has 24 million records. The Reference Qualifier reduces that down to 2 million. It was pointed out to me that a View might be a viable option so I am open to any ideas. I have attached a screenshot of the configuration of the dictionary. Here is the reference qualifier data:
"javascript: ['incident', 'problem', ].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join()"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 05:53 AM
To convert a reference qualifier into an encoded query in ServiceNow, you can use the "Advanced" option in the reference field's "Reference Qualifier" field. Here are the steps to follow:
1 Open the form or list where the reference field is located.
2 Right-click on the reference field and select "Configure Dictionary" from the context menu.
3 In the "Dictionary Entry" form, scroll down to the "Reference Qualifier" field.
4 Click on the "Advanced" button to open the "Advanced Reference Qualifier" dialog box.
5 In the dialog box, you can write your reference qualifier as you would normally. However, instead of returning a boolean value, you will need to return an encoded query string.
6 To encode the query string, use the "encodeURIComponent()" JavaScript function. For example:
javascript
Copy code"u_department=" + encodeURIComponent(g_user.department)
7
In this example, we are checking the "u_department" field against the current user's department. The encodeURIComponent() function will properly encode the user's department so that it can be used in an encoded query string.
8 Once you have written your reference qualifier and encoded it, click the "Update" button to save your changes.
9 Test your reference field to make sure it returns the expected values.
With these steps, you have converted your reference qualifier into an encoded query in ServiceNow. This approach allows you to use more advanced conditions and functions in your reference qualifier, while still ensuring that the reference field returns only valid values.
please mark this as correct and helpful , if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 06:21 AM
I will most definitely try this out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 06:26 AM
Sure, please mark my answer correct if it helps.