Set dynamic filter on reference field lookup list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 02:19 AM
Hello,
On the incident form, there is a Problem reference field. This field has a lookup list view option which then displays more info on the Problems in the table.
In the incident form, we also have an 'IT Service' field. This field is also present in the Problem lookup list as a column header named 'Affected IT Service'. Is it possible to have the Problem reference field lookup list dynamically filter when the IT Service field's value is changed on the incident form?
For example, if the IT Service field has a value of 'X App' then the Problem reference field will automatically then filter to only show Problems with the Affected IT Service of 'X App' too?
I was thinking this might be achievable using the Reference Qualifiers in the dictionary of the field? I had found this for changing other reference qualifiers but this doesn't have anything for dynamically changing the filter... https://www.servicenow.com/community/developer-forum/how-to-set-custom-filter-in-lookup-window/m-p/1...
Many thanks in advance..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 02:41 AM
You can use Advanced reference qualifier on Problem field in incident form , as you mentioned using Configure dictionary:
//use backend values of field
javascript:
var query;
if(current.getValue("IT Service")){
query = "Affected IT Service=" + current.getValue("IT Service");
} else {
// Query to show if "IT Service" field is empty
query = "your cutomized query";
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:06 AM
Hi Vishal, thank you for your fast reply!
I have attempted this but I've hit some issues. Note, I referenced the incorrect field so I have amended your script. Instead of 'IT Service' it's actually 'Affected IT Service or Application'. The script I used following your help was:
javascript:
var query;
if(current.getValue("Search IT Service or Application")){
query = "Affected IT Service=" + current.getValue("Search IT Service or Application");
} else {
// Query to show if "IT Service" field is empty
query = "your cutomized query";
}
This is how it is displayed in the Reference Qualifier:
The below shows the incident form and the problem lookup list when the script is in action:
See below reference screenshots too, these show the ServiceNow service and a test problem open for it too:
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:15 AM
use the backend name of field highlighted in red.
var query;
if(current.getValue("Search IT Service or Application")){
query = "Affected IT Service=" + current.getValue("Search IT Service or Application");
} else {
// Query to show if "IT Service" field is empty
query = "your cutomized query";
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:36 AM
Thank you Vishal.
I have amended the script to the below:
var query;
if(current.getValue("u_affected_service")){
query = "cmdb_ci=" + current.getValue("u_affected_service");
} else {
// Query to show if "cmdb_ci" field is empty
query = "your cutomized query";
}
But, the Problem lookup list just appears as empty still unfortunately.