created encoded query to get sys_created on 30 days ago

Suzanne_Ryan
Giga Expert

I have a scheduled job that runs daily, checking for records in a table that need to be processed.

The parameters are that the field "u_reminder_complete" is FALSE, and that the sys_created_on date is 30 days ago.

This scheduled job works perfectly when I comment out the eQuery line. 

I've tried every dang permutation of this query that I can think of and I've scoured both the product docs and the community and nothing I have tried works.

 

Thanks in advance.

Here's the code:

var eQuery = "sys_created_onRELATIVEGE@dayofweek@ago@30";

var app = new GlideRecord('u_reboot_exception_expiration'); 
app.addQuery('u_reminder_complete','false');
//app.addQuery('sys_created_on','>','gs.daysAgo(30)'); 
app.addEncodedQuery(eQuery);
app.query(); 
while(app.next()){  
//gs.eventQueue('open.costpoint.reminder', app, app.approver);
  gs.log('found a record ' + app.u_computer_number); 
  var cart = new Cart(); 
  var item = cart.addItem("319bedccdbdeaf00f0ad6f13ca9619f0");  //reboot removal
 cart.setVariable(item, "rfw_req_name6", app.u_employee_name);
 cart.setVariable(item, "rfw_req_short6", "Remove Reboot Exception for"+app.u_computer_number);
 cart.setVariable(item, "rfw_req_detail6", app.u_computer_number + ' - It has been 30 days since this exception was set.  IT will now remove the reboot exception from this computer.');
 cart.setVariable(item, "rfw_req_assgGroup6", "0ad44fd345f7e00072f83215afc7a609"); //Security
 cart.placeOrder(); 

 app.u_reminder_complete = true;
  app.update();

1 ACCEPTED SOLUTION

Can you try this query

sys_created_onRELATIVELE@dayofweek@ago@30

 

View solution in original post

7 REPLIES 7

Can you try this query

sys_created_onRELATIVELE@dayofweek@ago@30

 

Suzanne_Ryan
Giga Expert

 

Interesting.  That got both of the items with a created date of 12/8 AND the one with the 12/10 date.  We may be okay on that because it probably falls within 24 hours of the 30 day mark. 

 

I changed the created date for that one from the 10th to the 11th, ran it again, and it only got both of them from the 8th. Which is what I wanted!

 

I think this will work!

 

Thank you!

Mridul Srivasta
Tera Contributor
var gr = new GlideAggregate('sys_user');
gr.addQuery('sys_created_on', '>=', gs.daysAgo(7));
gr.addAggregate('COUNT');
gr.query();
var count = 0;
if(gr.next()) {
    count = parseInt(gr.getAggregate('COUNT'));
}
gs.log("Counting the number of records  : " + count);