- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 12:54 AM
Hi,
in catalog items, i have one filed, documents submit "Last End Date" (variable in catalog item)
ex: Last End Date=20/08/2018 19:50:20 then notification trigger one month before means on 20/07/2018.
So how can we do it.
my Br script is not working...
if(gs.dateDiff(gs.nowDateTime(), current.variables.ex_date.getDisplayValue(),true)/3600>=720)
{
var gdt = new GlideDateTime(current.variables.ex_date.getDisplayValue());
gdt.addDaysLocalTime(-30);
gs.eventQueueScheduled ( "thirty" , current, gs. getUserID ( ) , gs. getUserName ( ) , gdt) ;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 04:05 AM
Hi Chanikya,
You need to use your variable instead of my column name. Also I think you need to run this only for specific catalog item so if yes then add that query as well.
try this:
send1streminder();
function send1streminder() {
var task = new GlideRecord('sc_req_item');
task.addQuery('active', 'true');
var encodedQuery = task.variables.ex_date + 'RELATIVEGE@dayofweek@ahead@30^' + task.variables.ex_date + 'RELATIVELE@dayofweek@ahead@31';
task.addEncodedQuery(encodedQuery);
task.query();
while(task.next()){
gs.eventQueue('last_date', task, gs.getUserID(), gs.username());
}
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 01:42 AM
Hi Chanikya,
Yes that should be fine. in that query instead of u_sample_data you can have gr.variables.<dateVariable> and check
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 03:08 AM
How can query variable in script
send1streminder();
function send1streminder() {
var task = new GlideRecord('sc_req_item');
task.addQuery('active', 'true');
task.addEncodedQuery('u_sample_dateRELATIVEGE@dayofweek@ahead@30^u_sample_dateRELATIVELE@dayofweek@ahead@31');
task.query();
while(task.next()){
gs.eventQueue('last_date', task, gs.getUserID(), gs.username());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 04:05 AM
Hi Chanikya,
You need to use your variable instead of my column name. Also I think you need to run this only for specific catalog item so if yes then add that query as well.
try this:
send1streminder();
function send1streminder() {
var task = new GlideRecord('sc_req_item');
task.addQuery('active', 'true');
var encodedQuery = task.variables.ex_date + 'RELATIVEGE@dayofweek@ahead@30^' + task.variables.ex_date + 'RELATIVELE@dayofweek@ahead@31';
task.addEncodedQuery(encodedQuery);
task.query();
while(task.next()){
gs.eventQueue('last_date', task, gs.getUserID(), gs.username());
}
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 05:50 AM
Hi,
Script is working fine, but it is triggering all items records ..
here i have 11,12,13,14,15 /08/2018 dates RITM's of ACCESS(item) , but here i am getting total RITM's numbers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 06:13 AM
i have used below script,It is Working successfully
send1streminder();
function send1streminder() {
var task = new GlideRecord('sc_req_item');
task.addEncodedQuery('active=true^variables.4feba815db131300fc3164d7489619c4RELATIVEGE@dayofweek@ahead@30^variables.4feba815db131300fc3164d7489619c4RELATIVELE@dayofweek@ahead@31');
task.query();
while(task.next()){
gs.eventQueue('last_date', task, gs.getUserID(), gs.username());
}
}