Pull back a list of incidents related to a problem between date ranges (dateobj.addDays)

as a follow up to the last post, in a background script GlideRecord query:


var grPRB=new GlideRecord('problem');
var grINC=new GlideRecord('incident');

//if (grPRB.get('number', 'PRB0040954')){
if (grPRB.get('number', 'PRB0042424')){
    var prbArr= grPRB.sys_created_on.split(' ');

    gs.print(prbArr[0]);

    var dateObj= new GlideDateTime(grPRB.sys_created_on);
    dateObj.addDays('31');
    var DatePlus30= new GlideDateTime(dateObj);
    gs.print(dateObj);
    gs.print(DatePlus30);

    var prbArr2= DatePlus30.toString().split(' ');
    gs.print(prbArr2[0]);
  
   // var sDatesQuery="sys_created_on>=javascript:gs.dateGenerate('" + prbArr[0].toString() + "','00:00:00')^sys_created_on<=javascript:gs.dateGenerate('" + prbArr2[0].toString() + "','00:00:00')";

var sDatesQuery="sys_created_on>=javascript:gs.dateGenerate('" + prbArr[0].toString() + "','00:00:00')^sys_created_on<=javascript:gs.dateGenerate('" + prbArr2[0].toString() + "','00:00:00')";

gs.print(sDatesQuery);

grINC.addQuery(sDatesQuery);
   grINC.query();
    gs.print(grINC.getRowCount());

    while (grINC.next()){
       gs.print(grINC.number + '; ' + grINC.sys_created_on);
    }

}




Comments

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue