Last Month/ This Month Reports - Add Month Name to Title
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2017 09:20 AM
Hello,
Is there a way to dynamically add the month name to a report title on a gauge where the report is on "Last Month", "This Month" etc?
Just a thought...
Cheers,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2017 12:13 PM
Dan, I do not know of a way to do this within a Gauge or Report itself, but this could be done using a dynamic content block as part of a CMS website, or a UI Page for an internal dashboard System UI Widget. Adding the dynamic report header may not actually be needed depending upon the report(s) you are going to display. I did this for a client's change reports , but since these were calendar reports, there was no need to show the month, as that is already part of the title dynamically for that type of report.
Option 1:
"Dynamic" Change Report (using 'Calendar' Report Type)
Option 2:
but if you are using a non-Calendar type of report, such as List, Bar Graph, etc..,
then you'll need to setup your own header, and create an iFrame to show the various reports in
Here is some of the code you'd need to accomplish this type of layout that users could add to their homepage
SUMMARY
Step 1) Create a Custom UI Page
Step 2) Create a Custom System UI Widget to allow users to choose your custom UI Page to add content to their homepage
=====================================================================================
Detailed Step 1) Create Custom UI Page
Name: ReportsiFrame (or whatever name you want to call it)
Category: General
HTML:
===========================================
<?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>
.mytable {
width: 100%;
border: 1px solid;
}
#adm td:nth-child(even) {
text-align: center;
width: 150px;
color: #000000;
background-color: #fffff;
}
#adm td:nth-child(odd) {
text-align: center;
width: 150px;
color: #000000;
background-color: #f1f1f1;
}
</style>
<g:evaluate>
var t1 = new GlideDateTime();
var curr_ = getMonthName(t1.getMonthLocalTime());
var t2 = new GlideDateTime();
t2.addMonthsLocalTime(-1);
var prev_ = getMonthName(t2.getMonthLocalTime());
var t3 = new GlideDateTime();
t3.addMonthsLocalTime(+1);
var next_ = getMonthName(t3.getMonthLocalTime());
function getMonthName(mm) {
var monthNames = [ "Janurary", "Feburary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
return monthNames[mm - 1 ];
}
</g:evaluate>
<center><h3><div id="mytitle" name="mytitle">Change Calendar Report for ${curr_}</div></h3></center>
<TABLE id="adm" class="mytable"><TR>
<TD><div class="class1"><a href="#" onclick="setframe('sys_report_template.do?jvar_report_id=(report 1 sysid)${AMP}sysparm_calstyle=approval','${prev_}');" target="Calendar_iFrame"><img height="16" src="images/nav_backward1.gifx" width="16"></img> View Last Month</a></div></TD>
<TD><div class="class1"><a href="#" onclick="setframe('sys_report_template.do?jvar_report_id=(report 2 sysid)${AMP}sysparm_calstyle=approval','${curr_}');" target="Calendar_iFrame"> View Current Month </a></div></TD>
<TD><div class="class1"><a href="#" onclick="setframe('sys_report_template.do?jvar_report_id=(report 3 sysid)${AMP}sysparm_calstyle=approval','${next_}');" target="Calendar_iFrame"> View Next Month <img height="16" src="images/nav_forward1.gifx" width="16"></img></a></div></TD>
</TR></TABLE>
<TABLE><TR><TD>COLOR LEGEND: </TD><TD BGCOLOR="lightgreen">APPROVED</TD><TD> </TD><TD BGCOLOR="khaki">REQUESTED</TD></TR></TABLE>
<iframe id="frame1" src="sys_report_template.do?jvar_report_id=701bd6bd0f385600081ccfdce1050ee2" name="Calendar_iFrame" width="100%" height="900px"></iframe>
</j:jelly>
=========================================
Client Script
var myIframe = document.getElementById('frame1');
myIframe.addEventListener("load", function() {
this.contentWindow.document.getElementById("reportform_control").style.display='none'; // hide report controls from users
});
function setframe (url, title) {
var x1 = document.getElementById('mytitle');
x1.innerHTML = "Change Calendar Report for "+title;
var x2 = document.getElementById('frame1');
x2.setAttribute('src', url);
}
=========================================
Step 2) Create Custom System UI Widget
(this will allow users to use the ADD CONTENT on their homepage)