How to get day and month, Year

Sironi
Kilo Sage

Hi,

please help me in Date , it could not getting Month and year. displaying undefined 

Business Rule: Incident  , Update, Before

var cdate=current.u_date_needed;
var d = new Date();
var hh = d.getHours();
var date=0;
gs.addInfoMessage(gs.getMessage(hh));---------------------getting correct local user hours -------
var dd = String(d.getDate()).padStart(2, '0');
var mm = String(d.getMonth() + 1).padStart(2, '0'); 
var yyyy = d.getFullYear();
var today=yyyy+'-'+mm+'-'+dd;
gs.addInfoMessage(gs.getMessage(today));         -------------2019-undefined-undefined
gs.addInfoMessage(gs.getMessage(cdate));
if(today>=cdate)
{
if (hh > 7)
{
current.state='Closed Incomplete';
}
}

16 REPLIES 16

CAn you suggest me  here please , Need to close INC before one day

my Date Needed is : 10-09-2019

so i want to close incident one day before , means on 09-09-2019 at 7AM morning

 

is it correct process ??

var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_state!=Completed^ORu_state!=Closed Incomplete');
gr.addQuery('sys_created_on','<','u_date_needed');
gr.addEncodedQuery('active=true^u_date_neededRELATIVEGE@dayofweek@ahead@1^u_date_neededRELATIVELE@dayofweek@ahead@1');
gr.query();
while(gr.next())
{
var d = new Date();
var hh = d.getHours();
if (hh > 7)
{
current.state='Closed Incomplete';
}else
{

}
}

I assume this is a scheduler. Then all you need to do is query the incident table and update it. Run the scheduler a 7 AM in the morning, which should take care of it.

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_state!=Completed^ORu_state!=Closed Incomplete');
gr.addQuery('sys_created_on','<','u_date_needed');
gr.addEncodedQuery('active=true^u_date_neededRELATIVEGE@dayofweek@ahead@1^u_date_neededRELATIVELE@dayofweek@ahead@1');
gr.query();
while(gr.next())
{
current.state='Closed Incomplete';
current.update();
}


Please mark this response as correct or helpful if it assisted you with your question.