
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 08:11 AM
Hi,
I want to display the pm_project->description field in a content block, so I can apply some formatting to it. I assume it has to be a dynamic content block, since it needs to get the values. I am using a Cascading Filter to get to the pm_project record. Looking for help with the script to be based on the cascading filter results, when click "apply"
The screenshot shows how it looks using a List Report, Do not want the underlining and the run on text, where the description has returns in it.
Solved! Go to Solution.
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 10:41 AM
Yes, you can do it, but it isn't simple. If you went to K19, there was a lab on custom interactive filters and custom visualizations that has some sample code that may help. You have to look at the filters that are set (try starting wtih SNC.canvas.interactiveFilters.defaultValues). You'll then need to process that information to parse out what you are looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 10:41 AM
Yes, you can do it, but it isn't simple. If you went to K19, there was a lab on custom interactive filters and custom visualizations that has some sample code that may help. You have to look at the filters that are set (try starting wtih SNC.canvas.interactiveFilters.defaultValues). You'll then need to process that information to parse out what you are looking for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 11:12 AM
Hi Adam,
Thanks as always.... I am regretting not going to K19 now:-(
Thanks for the tip with SNC.canvas.interactiveFilters.defaultValues
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2020 09:46 AM
Hi Andrew,
Did you get this to work? I am attempting to do the same -- I would like the dynamic content block to display project description upon selection of a project.
I'm having a lot of difficulty with getting the content block to respond to an interactive filter though. I currently have a filter built into the block for troubleshooting purposes, but of course none of the other reports on my dashboard respond:
<?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 for 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'
});
This code spits out the "Project Description" block below (picture provided includes dummy data). Rather than using the filter I had created here (blue star), I would like the project description to populate based on selection from the filter above it.
Were you able to accomplish this or something similar?
Any advice would be immensely appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 11:37 PM
Hi @Andrew Payze ,
Did you find any solution for this? I have similar kind of requirement.
Thanks in advance!