- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018 11:41 PM
Hi all,
i have some reports which need dynamic title.
i have the code to do it. but it is very long and not that efficient.
ar a = new GlideRecord('sys_report');
a.get('9d2afa8affaec3');
a.title = 'Monthly Request KPI by OE - Summary for '+getMonth();
a.update();
var b = new GlideRecord('sys_report');
b.get('3D756e18aad1effaef1');
b.title = 'Monthly Request KPI by OE - Summary for '+getMonth();
b.update();
var c = new GlideRecord('sys_report');
c.get('466991ae71fedb6b52be');
c.title = 'Monthly Request SLA- Service Family for '+getMonth();
c.update();
var d = new GlideRecord('sys_report');
d.get('3Ddc3ef28e6d7edb8056e18aad1effaeae');
d.title = 'Monthly Request SLA - Summary'+getMonth();
d.update();
var e = new GlideRecord('sys_report');
e.get('3D0be6484cc85ebb5e8bc');
e.title= 'Monthly Request KPI by Provider-Summary for'+getMonth();
e.update();
var f = new GlideRecord('sys_report');
f.get('3D69ab37cba52ebb5e852');
f.title= 'Breached CTASKS by Assignment Group - Summary'+getMonth();
f.update();
var g = new GlideRecord('sys_report');
g.get('3Daa7936b3c8c75700547cba52ebb5e862');
g.title= 'All CTASK by Service Family for'+getMonth();
g.update();
function getMonth() {
var monthNames = ',December,January,February,March,April,May,June,July,August,September,October,November'.split(',');
var gdt = new GlideDateTime();
var month=(monthNames[new GlideDate().getMonthLocalTime()]+":"+gdt.getYear());
return month;
}
Any one know how to short this using loops or something..
please post answer if you know..
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 02:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 01:26 AM
Hi,
Make array of object which contains sys_id and title then iterate over that array like below.
//add as many objects you want.
var Arr = [{
sys_id : 'gfagsagagetge', //update with your id
title : 'Monthly Request KPI by OE - Summary for '+ getMonth();
},{
sys_id : 'fsagdsahgdhgdsahsh', //update with your id
title : '2nd report title '+ getMonth();
}];
Arr.forEach(function(item){
var a = new GlideRecord('sys_report');
a.get(item.sys_id);
a.title = item.title;
a.update();
})
Mark my ANSWER as CORRECT / HELPFUL if it served your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 01:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 02:02 AM
Try below, month will be a numeric value, you will have to add an script to print as alphabetical one.
var gdt = new GlideDateTime();
var month = gdt.getMonth();
var Arr = [{
sys_id : 'gfagsagagetge', //update with your id
title : 'Monthly Request KPI by OE - Summary for '+ month
},{
sys_id : 'fsagdsahgdhgdsahsh', //update with your id
title : '2nd report title '+ month
}];
Arr.forEach(function(item){
var a = new GlideRecord('sys_report');
a.get(item.sys_id);
a.title = item.title;
a.update();
});
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 02:17 AM
thanks vigneesh .. this works.
i changed the script a little to get month in aphabets
var monthNames = ',December,January,February,March,April,May,June,July,August,September,October,November'.split(',');
var gdt = new GlideDateTime();
var month=(monthNames[new GlideDate().getMonthLocalTime()]+":"+gdt.getYear());
var Arr = [{
sys_id : '1630026eb6512a2dc34d3', //update with your id
title : 'Monthly Request KPI by OE - Summary for '+ month
},{
sys_id : '46f1481cc7ccf9763d3', //update with your id
title : '2nd report title '+ month
}];
Arr.forEach(function(item){
var a = new GlideRecord('sys_report');
a.get(item.sys_id);
a.title = item.title;
a.update();
});