Regarding creation of notification when catalog task is not being closed after 1 week

Shreya3
Tera Contributor

how we can built from scratch the code for creating notification to be sent to technology Ci Owner manager and cc technology ci owner and suppport group if catalog task has not yet been closed after 1 week. And also need help for creating notification to be sent to technology Ci Owner manager and cc technology ci owner and suppport group to create p1 incident and then send email if catalog task has not yet been closed after 2 weeks . please help on this. I have created  2 event registry  , 2 email notification and 1schedule job. but in schedule job i am not able to put proper code for both of the scenarios can anybody help on this asap, as I am new to this.

26 REPLIES 26

Hi @Shreya3, 

 

I tried to rectify the script given by you and what I am able to understand and get it from this is: -

  1. Your filter applied and used in an "Encoded Query" seems not to be correct. I applied it on my Personal Developer Instance and what I am able to get it from your query is not correct and added the screenshot for your reference.
  2. It seems that you have written the "eventQueue" in while loop, So, it will trigger the notifications as many as records will be there.

Finally, you need to rethink and apply the filter correctly and move the eventQueue out of the while loop.

 

Hope this guidance and solution will work for you now and please don't forget to mark my solutions and replies as helpful and accepted. 

 

Thanks 🙂

Aakash Garg

ServiceNow Developer

akash for this code:

var abc= new GliderRecord("sc_task");

abc.addEncodedQuery('sys_created_onRELATIVELT@dayofweek@ago@2^sys_created_onRELATIVEGT@dayofweek@ago@3^state!=4'); 

abc.query();

while(abc.next()){

gs.eventQueue("demo.event.sox" , abc);

}

i have thought what i could put for filter but even if i have taken out eventqueue out of while loop now it is not sending notification to user. can you provide me code by modifying this code which i have sent so that i can figure out where i am going wrong.

And yes thank you for showing patience and cooperation to each and every question I have asked you and replying to it. Glad that even in your busy schedule you are giving so much time. Thank you for helping whatever you could do from your end

Hi @Shreya3,

 

Really Appreciate your appreciation and words towards me and my work and this becomes my responsibility to get your ask or question gets resolved as soon as possible and this is what I am trying to achieve.

 

Attaching the script for your reference and hope this will fulfil your requirement. I personally made and tried it on my Personal Developer Instance.

 

Schedule Job: -

tasks_2days = [];
var abc= new GlideRecord("sc_task");
abc.addEncodedQuery('sys_created_onRELATIVELT@dayofweek@ago@2^sys_created_onRELATIVEGT@dayofweek@ago@3^state!=4'); 
abc.query();
while(abc.next()){
	tasks_2days.push(abc.sys_id.toString());
}
if (tasks_2days.length!=0){
	gs.eventQueue("demo.event.sox" , abc, tasks_2days);
}

 

For your reference, also attaching screenshots of the schedule job that will give you better insights or the best thing will be to follow the solution and execute the script on your instance.

 

If you find this answer/solution/suggestion as helpful to your question asked or meet with your requirement, you can mark this solution/answer/suggestion as helpful, and correct.

 

Thanks 🙂

Aakash Garg

ServiceNow Developer

Akash 

var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery('workflow_state=published^active=true^valid_toRELATIVEEE@dayofweek@ahead@1');
gr.query();
 
while (gr.next()) {
gs.eventQueue("knowledge.expiring", gr);
}
this code i got from community only and it is working for others i have also tried to used this type of code so why it is not working?

Hi Akash , Do you know how and where we can add CC people in notification. for example in who will receive tab i am able to add people in user/group field but how to put CC people? can you provide example please.