How to get current month in the Schedueld report Subject

vspk
Giga Expert

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

15 REPLIES 15

anjalichoudhary
Kilo Guru

Hi Sneha,



You can create a Script Include to fetch the current month as below and then call that Script include in your report subject:



var test = Class.create();


test.prototype = {


    currMonth : function()


  {


  var gdt = new GlideDate();


  var ans = gdt.getByFormat("MMMM");


  return ans;


  }


};  



Call this Script Include in Report Subject as:



javascript:"This report is   for " +currMonth();



Please mark Correct or Helpful as per impact of Response!!



Thanks,


Anjali


Hi Anjali,



I tried it but the subject is coming blank



Regards,


Sneha


PriyaRanji
Tera Guru

Hi Priya,



Good Day



getMonth() - hellps to get the current month value.



Please find the below code for the same.


var gdt = new GlideDateTime();


gs.print("The Current Month is" + " "+ gdt.getMonth());



Output :- The Current Month is 8



It will returns the numerical value of the month, Jan=1,...............Dec=12.



Please mark Correct or Helpful if it helps you out



Thanks,


Priyanka R


Hi Priyanka,



I tried the same. I put the above code in script include and called it in the subject of scheduled report. but the report is coming with blank subject




Regards,


Sneha