How to create a Dynamic Content Block using info from Interactive Filter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 10:17 AM
Hello,
I try to create a Dynamic Content Block to show dynamically the selected field from a Interactive filter.
I 've been using Jelly to show the field. I need obtain the sys_id selected from intercactive filter.
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var message = [dynamic_filter_value_selected];
</g:evaluate>
Project Name:${message}<br/>
</j:jelly>
- Labels:
-
Performance Analytics
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 10:37 AM
I think this won't work in Jelly. Interactive Filters live on the client side. You might be able to listen to the DashboardMessageHandler or you can find the JavaScript property that has this and read it in. Then you'll have to call the TableAPI yo translate the element value (what is selected in the filter).
If you went to knowledge, take a look at the CreatorCon session on Customer Interactive Filters and Custom Visuals. This may give you some code you can leverage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2020 11:08 AM
Hello all,
I'm trying to figure out how to get a dynamic html content block to display the description of a project when a project is selected from an interactive filter. Might anyone have any suggestions as to how I can do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2020 11:46 AM
You have to treat it as a custom report (that is displayed as formatted text). The lab referenced above has some examples of how to subscribe to the DashboardMessageHandler events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2020 08:35 AM
Hi Adam,
I've been looking at this, but I'm still pretty lost. By custom report, do you mean script-generated custom chart...?
Using the dynamic content block, I was able to make a filter and pull up the project description. The only thing is that nothing else on my dashboard responds to this filter...nor can I get this block to follow the interactive filter on my dashboard (which would be more ideal).
How can I leverage DashboardMessageHandler to connect these last
In case if you wanted to check it out:
<?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_tasktypes" object="true" jelly="true">
var objs = [];
var gr= new GlideRecord('pm_project');
gr.query();
while(gr.next()){
objs.push({'sys_id': gr.getValue('sys_id'),'short_description':gr.getDisplayValue('short_description')});
}
objs;
</g:evaluate>
<div class="container">
<div class="col-md-3">
<div class="panel-body">
<h4>Project Selection</h4>
<select id='filter_task_type' class='select2-search form-control' onchange='filterTaskType()'>
<option value="">All</option>
<j:forEach var="jvar_tasktype" items="${jvar_tasktypes}">
<option value="${jvar_tasktype.sys_id}">${jvar_tasktype.short_description}</option>
</j:forEach>
</select>
</div>
</div>
<div class="col-md-9">
<div class="panel-body">
<div id="incDetails">
<div class="list-group"></div>
</div>
</div>
</div>
</div>
<script>
function filterTaskType(){
var container = document.querySelector('.container');
var taskType = container.querySelector('#filter_task_type').value;
var incDetails = container.querySelector('.list-group');
//GlideAjax Script Include
var ga = new GlideAjax('ProjInfoUtil');
ga.addParam('sysparm_name', 'getProjInfo');
ga.addParam('sysparm_task_type', taskType);
ga.getXML(callback);
function callback(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
var details = JSON.parse(result);
var keys = Object.keys(details[0]);
var html = [];
keys.forEach(function(key){
var label = key.toUpperCase().replace("_", " ");
var text = details[0][key];
html.push('<div class="list-group-item"><h4 class="list-group-item-heading">'+ label + '</h4>');
html.push('<p class="list-group-item-text">' + text + '</p></div>');
});
incDetails.innerHTML = html.join("");
}
}
</script>
</j:jelly>
Script Include:
var ProjInfoUtil = Class.create();
ProjInfoUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getProjInfo: function(){
var taskType = this.getParameter('sysparm_task_type');
gs.log("Task Type: " + taskType, "Select EX");
var gr = new GlideRecord("pm_project");
gr.get(taskType);
var fields = ['description'];
var bu = {};
if (gr.getUniqueValue()){
fields.forEach(function(field){
bu[field] = gr.getValue(field);
});
}
return JSON.stringify([bu]);
},
type: 'ProjInfoUtil'
});
I appreciate the help!