Jelly script to search an item in Dashboard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 08:02 AM - edited ‎10-11-2022 08:13 AM
Hi Experts,
I have written a jelly script on cmdb_rel_ci table to create a filter, which I need to search either by parent or by child in the dashboard interactive filter. where dashboard have a report on cmdb_rel_ci table. If I search by either parent or child in the interactive filter , In report I should be able to see the related record to that search item. As of now with the below script logic where I can search by only parent or only by child,[filter_message.filter = "childSTARTSWITH"+ searchTerm;] But my requirement is to search either by parent or child [search item should be both either parent or child]. how can I add "OR" condition over here. Kindly help me on this
Script:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<style>
</style>
<script>
var my_dashboardMessageHandler = new DashboardMessageHandler("FilterName");
function publishFilter (searchTerm) {
var filter_message = {};
filter_message.id = "FilterName";
filter_message.table = "cmdb_rel_ci";
if (searchTerm == ""){
clearFilter();
}
else {
filter_message.filter = "childSTARTSWITH"+ searchTerm;
}
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
}
function clearFilter() {
var filter_message = {};
filter_message.id = "FilterName";
filter_message.table = "cmdb_rel_ci";
filter_message.filter = "";
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.removeFilter();
}
</script>
<input id="searchTerm" type="text" class="form-control" value="" onchange="publishFilter(this.value);"></input>
</j:jelly>
Thanks in advance
Chaithanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 08:12 AM
I see your solution on other threads which are related to Jelly Script. Kindly help me on this .
Thanks.