- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 12:03 AM
Hi, I am writing a Dynamic content script while making a dashboard.
I wonder how the <g:evaluate> part in dynamic content script works.
What I want is, If I select the value of the selectbox, I want to set the value to change as the glide query in the <g:evaluate> part works.
The xml below is an example that I have written. I hope it works like this.
I wrote an explanation on the comment.
Can anyone tell me if there is a way and how to do it?
<?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 locationMessageHandler = new DashboardMessageHandler("location_filter");
var itemSys = "";
var itemName = "";
$j(document).ready(function() {
$j(".js-example-basic-single").select2();
});
function addItem(){
var selectBox = document.getElementById("list");
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
var selectedLabel = selectBox.options[selectBox.selectedIndex].label;
if(selectedValue!="all"){
itemSys = selectedValue; <!-- This is the value I want to use. -->
itemName = selectedLabel;
}
}
</script>
<g:evaluate>
var list = [];
var gr = new GlideRecord('u_common_codes');
gr.addQuery('u_code_class','task_type');
gr.addQuery('active',true);
gr.query();
while(gr.next()){
var type = {
name: gr.u_name.toString(),
sys: gr.sys_id.toString()
};
list.push(type);
}
<!-- Query that must be run each time the value of the selectbox is selected -->
var accumulate_sales_rights = 0;
var ga=new GlideAggregate('u_software_sales_actual_summary');
ga.addQuery('u_task_type', itemSys ); <!-- itemSys (Value selected above)-->
ga.addAggregate('SUM','u_sales_rights');
ga.setGroup(false);
ga.query();
if(ga.next()){
accumulate_sales_rights= ga.getAggregate('SUM','u_sales_rights');
}
</g:evaluate>
<div>
<label>Task type</label>
<select class="js-example-basic-single" style="max-width:90%;min-width:50%;" id="list" onchange="addItem();">
<div class="form-horizontal container-fluid incident-category">
<option value="all"> ALL </option>
<j:forEach var="jvar_type" items="${list}">
<g:evaluate var="jvar_type" jelly="true">
var name = jelly.jvar_type.name;
var sys = jelly.jvar_type.sys;
</g:evaluate>
<option value="${sys}" label="${name}">${name} </option>
</j:forEach>
</div>
</select>
</div>
<div style="text-align:center">
<span style="font-size: 40px; background-color:green; padding: 0 10px;">
<h>${accumulate_sales_rights}</h> <!-- Where the result value is shown -->
</span>
</div>
</j:jelly>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 12:27 AM
Hi
unfortunately it is not really clear what you want to reach. Instead you are asking for a really special solution, but I have no idea whether this can work as provide all details.
But maybe my article regarding Interactive Dashboard Filters can help you understand the topic better: https://community.servicenow.com/community?id=community_article&sys_id=04e1c50cdbd98114382a826305961...
Kind regards
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 12:08 AM
Hi
This link should help you to understand :https://community.servicenow.com/community?id=community_question&sys_id=c4909369dbdcdbc01dcaf3231f96...
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 12:27 AM
Hi
unfortunately it is not really clear what you want to reach. Instead you are asking for a really special solution, but I have no idea whether this can work as provide all details.
But maybe my article regarding Interactive Dashboard Filters can help you understand the topic better: https://community.servicenow.com/community?id=community_article&sys_id=04e1c50cdbd98114382a826305961...
Kind regards
Maik