AddQuery for timestamp on Related List

Community Alums
Not applicable

I am working on the query on a related list that will show cases with same account and service offering that are opening in the last 30 days.  The below is my query. Everything is workiing but the timestamp piece. Please help.

 

current.addQuery('u_task_account', parent.u_task_account);
current.addQuery('service_offering', parent.service_offering);
gr.addEncodedQuery("sys_created_onONLast 3 months@javascript:gs.beginningOfLast3Months()@javascript:gs.endOfLast3Months()");

1 ACCEPTED SOLUTION

I just realized you're using gr and current objects.  For your encoded query, you need to change gr to current.  As it is, you have two different GlideRecord objects in use.  So your call to query() is only going to work with one of them in that piece of code.  

 

Or change current to gr.  This is probably what you want.  Without seeing the rest of your code, I'm assuming current is the already defined current object.

 

View solution in original post

4 REPLIES 4

Roger Poore
Tera Guru

Hey Shannon-

 

You said last 30 days but your encoded query is for the last 3 months.  Maybe try this instead:

current.addQuery('u_task_account', parent.u_task_account);
current.addQuery('service_offering', parent.service_offering);
gr.addEncodedQuery("sys_created_onONLast 30 days@javascript:gs.beginningOfLast30Days()@javascript:gs.endOfLast30Days()");

HTH

 -Roger

Community Alums
Not applicable

Originally they asked for 30 days but wanted to extend to 3 months. It doesn't work with either query unfortunately.

I just realized you're using gr and current objects.  For your encoded query, you need to change gr to current.  As it is, you have two different GlideRecord objects in use.  So your call to query() is only going to work with one of them in that piece of code.  

 

Or change current to gr.  This is probably what you want.  Without seeing the rest of your code, I'm assuming current is the already defined current object.

 

Community Alums
Not applicable

I updated the last line to the below:


current.addEncodedQuery("sys_created_on>javascript:gs.beginningOfLast90Days()");

 

It is working as expected now.