- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 12:12 PM
Our reporting team is looking to build an interactive filter on the Incident’s [caller_id] field, so that a report consumer can filter the incidents by Caller.
However, the display value is currently Name on the [sys_user] table. So the report consumer would use the Filter to choose a Caller by Name. For this specific report, however, the user needs to be able to choose the Caller by a different field (like Employee ID, for example) that is unique -- since Name is not unique.
I don’t want to change the display value on the [sys_user] table, since that is a platform-wide change, and different reports may want to use different “unique” fields (Username, Employee ID, Employee Code, Name, etc.). What options do we have for addressing this? I’ve done some research, and it doesn’t look like I can override the display value using a Database view.
Solved! Go to Solution.
- Labels:
-
Performance Analytics
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 01:56 PM
I don't know of a way to allow for searching on other fields other than the display value in an Interactive Filter.
Normally on a standard form field, you would add an attribute on the Caller field on the Incident Table, to allow to search for Multiple Fields on the User Record.
Example: Attribute ref_ac_columns=user_name
On the Incident Table Caller Field
You can search by User ID now as well as the Display Value
*However that does not seem to extend to Interactive Filters for searching.
I just created a Custom Interactive Filter that would allow you to search on the User ID. Works on my PDI
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
var callerIDDashboardMessageHandler = new DashboardMessageHandler("caller_id_search");
function publishCallerIDFilter() {
var filter_message = {};
filter_message.id = "caller_id_search";
filter_message.table = "incident";
<!-- Caller User Name Search -->
filter_message.filter = "caller_id.user_name=" + document.getElementById("caller_id_string").value;
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
callerIDDashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
}
function clearCallerIDFilter() {
var filter_message = {};
filter_message.id = "caller_id_search";
filter_message.table = "incident";
filter_message.filter = "";
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
callerIDDashboardMessageHandler.removeFilter();
}
</script>
<style>
input[type=text], select {
width: 100%;
padding: 5px 10px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
</style>
<form>
<input type="text" id="caller_id_string" name="caller_id_string" placeholder="User Name" onkeydown="if (event.keyCode == 13) return false;"/><br/>
<input type="button" value="Search" onclick="publishCallerIDFilter()"/>
<input type="button" value="Clear" onclick="clearCallerIDFilter(); document.getElementById('caller_idstring').value = ''"/>
</form>
</j:jelly>
Dashboard Test. I can search for the User ID and the incidents return that Caller's Incidents.
**Note there are some limitations to Custom Interactive Filters that you can learn about in the DOCS
If this was able to answer your question, please mark it as the Accepted Solution so the question will appear as resolved for other users who may have a similar question in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2021 01:56 PM
I don't know of a way to allow for searching on other fields other than the display value in an Interactive Filter.
Normally on a standard form field, you would add an attribute on the Caller field on the Incident Table, to allow to search for Multiple Fields on the User Record.
Example: Attribute ref_ac_columns=user_name
On the Incident Table Caller Field
You can search by User ID now as well as the Display Value
*However that does not seem to extend to Interactive Filters for searching.
I just created a Custom Interactive Filter that would allow you to search on the User ID. Works on my PDI
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
var callerIDDashboardMessageHandler = new DashboardMessageHandler("caller_id_search");
function publishCallerIDFilter() {
var filter_message = {};
filter_message.id = "caller_id_search";
filter_message.table = "incident";
<!-- Caller User Name Search -->
filter_message.filter = "caller_id.user_name=" + document.getElementById("caller_id_string").value;
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
callerIDDashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
}
function clearCallerIDFilter() {
var filter_message = {};
filter_message.id = "caller_id_search";
filter_message.table = "incident";
filter_message.filter = "";
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
callerIDDashboardMessageHandler.removeFilter();
}
</script>
<style>
input[type=text], select {
width: 100%;
padding: 5px 10px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
</style>
<form>
<input type="text" id="caller_id_string" name="caller_id_string" placeholder="User Name" onkeydown="if (event.keyCode == 13) return false;"/><br/>
<input type="button" value="Search" onclick="publishCallerIDFilter()"/>
<input type="button" value="Clear" onclick="clearCallerIDFilter(); document.getElementById('caller_idstring').value = ''"/>
</form>
</j:jelly>
Dashboard Test. I can search for the User ID and the incidents return that Caller's Incidents.
**Note there are some limitations to Custom Interactive Filters that you can learn about in the DOCS
If this was able to answer your question, please mark it as the Accepted Solution so the question will appear as resolved for other users who may have a similar question in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2021 05:42 AM
What is the navigation to write this jelly script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2021 07:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2022 10:40 AM
I ran into this issue/need as well, thanks for sharing your code! I submitted an idea to have this option implemented as an enhancement. Please upvote if you think it's a good idea. View Idea Page - ServiceNow Community