How to get current month in the Schedueld report Subject
This content was last updated in 2023. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 01:50 AM
Hi,
We are scheduling reports for monthly and daily incidents.
In the subject of that scheduled report, we need to show the current date and month for Daily and Monthly reports respectively.
I am able to set the date for daily report but I am facing issues to show the Month in monthly report.
Can anyone please help me here.
For the Daily report, this is the subject I am setting:
javascript:"Daily Report of incidents - " + gs.now();
It will send the email as: Daily Report of incidents - 08-02-2017
Similarly I want subject as: Monthly Report of incidents - August.
How to implement this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 02:35 AM
Hi Pri,
Ohk, I will check it and let you know!
Thanks,
Priyanka R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 02:37 AM
Hi Pri,
Can you please share your script include so that we can debug the code and get an idea like where it went wrong.
Thanks,
Priyanka R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 02:47 AM
Script include:
var Getmonth = Class.create();
Getmonth.prototype = {
getMonth: function() {
var gdt= new GlideDateTime();
var val=gdt.getMonth();
return val;
},
// type: 'Getmonth'
};
and in the report I am using: javascript:"Monthly Incident report-" + new Getmonth().getMonth();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 02:55 AM
Hi Pri,
Can you please add some logs to check :-
var Getmonth = Class.create();
Getmonth.prototype = {
getMonth: function() {
gs.log('inside 1');
var gdt= new GlideDateTime();
gs.log('The current month is'+" "+gdt.getMonth());
var val=gdt.getMonth();
gs.log('val'+val);
return val;
},
// type: 'Getmonth'
};
Thanks,
Priyanka R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 03:12 AM
Hi Pri,
I hope you will get the result in the script include, the issue with calling the script include from the report.
Case 1 : if you need the current month in name go with
var gdt = new GlideDate();
var result = gdt.getByFormat("MMMM");
var outputValue = "Monthly Incident report" + "-" + result;
outputValue : Monthly Incident report - August
Case 2 : if you need the current month in numerical value (int), go with
var gdt = new GlideDate();
var result = gdt.getMonth();
var outputValue = "Monthly Incident report" + "-" + result;
outputValue : Monthly Incident report - 8
Modify the same in your code.
From my point of view, the issue is with the one while calling the script include. Since both the conditions works fine
javascript: new Getmonth().getMonth(); /*call the script include in this way from the report*/
Hope it will helps you out
Thanks,
Priyanka R
Please mark Correct or Helpful as per impact!