"RELATIVEEE@dayofweek@ahead@30" is not sending notification 30 days prior to the expiration date. Help pls.

Rajini2
Mega Sage

I am trying to generate an expiration notification from my scheduled job. Notification should go 30 days prior to the expiration date, which is catalog variable.

The first query is what I am trying and failing variables.908016f5db9c3340a1d116494896199fRELATIVEEE@dayofweek@ahead@30

var gr = new GlideRecord("sc_task");	
// this does not work.
gr.addEncodedQuery('request_item.cat_item=3ae70705db98bf00a1d11649489619ed^state=3^assignment_group=eaf43fe9db603300a1d11649489619d7^variables.8410deb5db9c3340a1d116494896194b=Approve^variables.908016f5db9c3340a1d116494896199fRELATIVEEE@dayofweek@ahead@30^sys_created_onONLast 3 months@javascript:gs.beginningOfLast3Months()@javascript:gs.endOfLast3Months()');

Any help on this is highly appreciated.

Thanks.

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello Rajini,

Could you please check with below script once:

var expiryDateGDT = new GlideDateTime();
expiryDateGDT.addDays(30);
var expiryDate = expiryDateGDT.getDate();

var query = "request_item.cat_item=3ae70705db98bf00a1d11649489619ed^assignment_group=eaf43fe9db603300a1d11649489619d7^state=3^variables.8410deb5db9c3340a1d116494896194b=Approve^variables.908016f5db9c3340a1d116494896199fON" + expiryDate +"@javascript:gs.dateGenerate('" + expiryDate + "','start')@javascript:gs.dateGenerate('" + expiryDate + "','end')^sys_created_onONLast 3 months@javascript:gs.beginningOfLast3Months()@javascript:gs.endOfLast3Months()";

var gr = new GlideRecord("sc_task");	
gr.addEncodedQuery(query);

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

View solution in original post

5 REPLIES 5

Mahendra RC
Mega Sage

Hello Rajini,

Could you please check with below script once:

var expiryDateGDT = new GlideDateTime();
expiryDateGDT.addDays(30);
var expiryDate = expiryDateGDT.getDate();

var query = "request_item.cat_item=3ae70705db98bf00a1d11649489619ed^assignment_group=eaf43fe9db603300a1d11649489619d7^state=3^variables.8410deb5db9c3340a1d116494896194b=Approve^variables.908016f5db9c3340a1d116494896199fON" + expiryDate +"@javascript:gs.dateGenerate('" + expiryDate + "','start')@javascript:gs.dateGenerate('" + expiryDate + "','end')^sys_created_onONLast 3 months@javascript:gs.beginningOfLast3Months()@javascript:gs.endOfLast3Months()";

var gr = new GlideRecord("sc_task");	
gr.addEncodedQuery(query);

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

Thank you so much. It worked!

Hi @Mahendra RC ,

 

I have almost the same requirement. 

I have created a date (u_duration)field in the catalog form.

Suppose I am putting u_duration as 12/31/2024.

30 days before the Duration date is reached, we have to notify requested for and "abc" group that your ticket is expiring.

I posted this question in community. Please check and kindly provide me the solution.

https://www.servicenow.com/community/itsm-forum/send-notification-to-the-requested-for-and-the-abc-g... 

 

Thanks!

Samiksha

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

if the 2nd is working then what's the challenge?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader