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

SanjivMeher
Kilo Patron
Kilo Patron

Try

app.addEncodedQuery('u_reminder_complete=false^sys_created_onONLast 30 days@javascript:gs.beginningOfLast30Days()@javascript:gs.endOfLast30Days()')

instead of 

app.addQuery('u_reminder_complete','false');
//app.addQuery('sys_created_on','>','gs.daysAgo(30)');  

 

 

 


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

Suzanne_Ryan
Giga Expert

Thanks Sanjiv.  Unfortunately, this did not work.  Any other thoughts?

Is the schedule job created on custom application scope?

Suzanne_Ryan
Giga Expert

It isn't. 

 

I have two records in my table - created on 12/8 - and I would like the query to catch anything where the u_reminder_complete value is false and sys_created_on is 30 days or more.

 

The scheduled job will run every day so I could just do a query of "sys_created_on<=javascript:gs.beginningOfLast30Days()", which does work. 

That will catch anything exactly 30 days old, but I was hoping to get the security of having it catch anything older than 30 days that may have fallen through the crack.