Related lists: relationships - complex query (dates)

criteria:

a related list on problem form which displays incidents with same core categories, created within 30 days of the problem created on date:




(function refineQuery(current, parent) {
   
    // Add your code here, such as current.addQuery(field, value);
    //current.addQuery('u_category', parent.category);
    current.addQuery('category',parent.u_category);
    current.addQuery('subcategory',parent.u_subcategory);
    current.addQuery('u_subcategory_2',parent.u_subcategory_2);
    current.addQuery('u_subcategory_2',parent.u_subcategory_2);
   
    //current.addQuery('sys_created_onONLast 30 days@javascript:gs.daysAgoStart(30)@javascript:gs.daysAgoEnd(0)');
   
    //current.addQuery('active','true');
   
    var prbArr= parent.sys_created_on.split(' ');
    var dateObj= new GlideDateTime(parent.sys_created_on);
    dateObj.addDays('31');
    var DatePlus30= new GlideDateTime(dateObj);
    var prbArr2= DatePlus30.toString().split(' ');

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')";
   
    current.addQuery(sDatesQuery);
   
   
})(current, parent);

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