Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How do you create a searchbox (dynamic content) on a dashboard to perform a Keyword search to search for what is on the dashboard (a report that is looking at the sc_item_req table)

Jayvik
Tera Contributor

Hey, 

I need to create a searchbox (dynamic content item) on a dashboard to perform a Keyword search to search for what is on the dashboard (a report that is looking at the sc_item_req table).   

I saw someone creating a searchbox to look for CI's on an Incident table but I can't figure out how to do it for my scenario.  Any help is much appreciated 

1 ACCEPTED SOLUTION

Hello Jayvik,

Now that I'm at a computer here is the structure you would need to achieve your goal. 

Content Block named RITM Keyword Search:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_mapping" object="true" jelly="true">
    var mapping = [{"table": "sc_req_item", "filterPrepend": "123TEXTQUERY321=", "filterAppend": ""}];
    JSON.stringify(mapping);
</g:evaluate>
<g:macro_invoke macro="ritm_keyword_search" name="StringFilterContentBlock" mapping="${jvar_mapping}" />
</j:jelly>

 

UI Macro named ritm_keyword_search:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="${jvar_name}_if_display" class="form-horizontal" style="margin:0 10px 15px;">
<input id='${jvar_name}_if_text' class="form-control widget-content" value="" />
</div>
<div id="${jvar_name}_mapping" style="display: none">${jvar_mapping}</div>
<script>
	
    var tables${jvar_name} = JSON.parse($j("#${jvar_name}_mapping").text());
    // Widget information
    var if_obj${jvar_name} = $j("#${jvar_name}_if_display");
    
	//Generate and Set a DashboardHandler ID
    var if_widgetId${jvar_name} = if_obj${jvar_name}.closest(".grid-widget-content")[0].getAttribute("data-original-widget-sysid");
    
    var ${jvar_name}DMH = new DashboardMessageHandler(if_widgetId${jvar_name});
   //Set the text field
	var ${jvar_name}_text = $j('#${jvar_name}_if_text');
    
	// handle the field changes
    ${jvar_name}_text.change(function()
    {
        var filterObj = {id: if_widgetId${jvar_name}, filters: []};
        if (${jvar_name}_text.val().length > 0) {
            for(var t = 0; t &lt; tables${jvar_name}.length; t++)
            {
                
                filterObj.filters.push({
                    table: tables${jvar_name}[t].table,
                    filter: tables${jvar_name}[t].filterPrepend + ${jvar_name}_text.val() + tables${jvar_name}[t].filterAppend
                });
            }
            // add the filter
	        window.SNC.canvas.interactiveFilters.setDefaultValue({
				id: ${jvar_name}DMH, 
				filters: filterObj
				}, false);
            ${jvar_name}DMH.publishMessage(filterObj.filters);
        } else {
			 window.SNC.canvas.interactiveFilters.setDefaultValue({
				id: ${jvar_name}DMH, 
				filters: filterObj
				}, false)
            ${jvar_name}DMH.removeFilter();
        }
    });
</script>
</j:jelly>

 

Result:

find_real_file.png

Keyword on the ticket:

find_real_file.png


Please mark my answer as correct/helpful if it has helped you.

Thanks,
Logan

View solution in original post

5 REPLIES 5

Any chance you've taken a stab at this in the new Platform Analytics dashboards?