The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Dynamic Content Block for Keywords

Community Alums
Not applicable

The global search in the new experience only returns results of active records. The old global search would should show all results so you might get something like Change(0) because there are no active changes for the search term. The nice thing with the old search is you could click that link and remove active = true so you could see all changes related to the search term. This functionality is now gone so my users are asking for a way to search in this manner. 

 

I have create a report which searches all of the task table and groups by task type. Then I have an interactive filter so they can choose which task types (INC, CHANGE, etc). I then wanted to create a keyword search to allow them to further filter the results. To do so I built a dynamic content block but I can't get it to work. My understanding is that if I can build an encoded query from a list view this should be possible. Here is the code for this simple content block. When dropped onto my dashboard I can't get the report to update results based on the keyword. This video presentation from SN indicates this is possible though it was not shown, just mentioned. https://www.youtube.com/watch?v=8eM6l4v75gw&t=746s

 

 

<?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 my_dashboardMessageHandler = new DashboardMessageHandler("kw_search");

function searchForStrings (str){
var filter_message{};
filter_message.id = "kw_search";
filter_message.table = "task";

filter_message.filter = "123TEXTQUERY321=" + str;
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
},false);
my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
</script>
Kewyord<br/>
<input id="myCustomSearchString" type="text" value="" onChange="searchForStrings(this.value);" />
</j:jelly>

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Kim, I did get this to work and it's awesome. It has been so useful to be able to add this to dashboards. I attached the xml file below but here is the code as well. 

 

<?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("FilterShortDescription");

function publishFilter (searchTerm) {
var filter_message = {};
filter_message.id = "FilterShortDescription";
filter_message.table = "task";

if (searchTerm == ""){
clearFilter();
}
else {
filter_message.filter = "123TEXTQUERY321=" + searchTerm;
//filter_message.filter = "short_descriptionSTARTSWITH"+ 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 = "FilterShortDescription";
filter_message.table = "task";
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>

View solution in original post

5 REPLIES 5

Kim Sullivan
Tera Guru

Thanks Chris for the code share!  It worked.