The CreatorCon Call for Content is officially open! Get started here.

Script to determine age of a ticket

reeset
Kilo Contributor

Hi everyone.   I am happy you. All are here and can   hopefully assist me

i tried this through inactivity monitor but it doesn't work correctly. So I would like to use another method like scripyin and have the scripting trigger an email

The parameters are.   Check ll incidents if the incident is 30 days or more and still open,   trigger an email to go out to the assignee of ticket.   This should be done for all open, ain progress, pending or assigen.   Got all tickets that are found an email is sent to the assignee   and manager

i I don't want to use inactivity monitor.   I would like to use a script which fire off an email

does anyone already have something like this or able ti share how this Cavan be accomplished

THANK YOU,,,

24 REPLIES 24

Thanks, did you make 2 changes to the script code?   I don't see the details of the second one.   Can you cut and paste what script 1 and script 2 should be and I will update them both?



THANK YOU


Sure,



Conditional script:


  1. var ga = new GlideAggregate('incident');  
  2. ga.addAggregate('COUNT');  
  3. ga.addQuery('active', 'true');  
  4. ga.addQuery('sys_created_on', '<', gs.daysAgo(30));  
  5. ga.query();  
  6. ga.next();  
  7. ga.getAggregate('COUNT') !== '0';


Script:


  1. var gr = new GlideRecord('incident');  
  2. gr.addQuery('incident_state', '<', 6);  
  3. gr.addQuery('sys_created_on', '<', gs.daysAgo(30));  
  4. gr.query();  
  5.   gs.log('Business rule is running correctly');
  6.  
  7. while(gr.next()){  
  8.   gs.eventQueue("incident.unresolved", gr);  
  9. }  


After you trigger the scheduled script please go to Sytem Log -> All and do a search for 'Business rule is running correctly'.



Let me know if it works!


Unfortunately no its not working,   There is a syntax error in script one.   WHen I check syntax it returns an error, I don't know if it is critical or not.   Not sure if that could be the cause.



I tried an execute now and it doesn't do anything.   It executes the scheduled job but that's all.   I never see incident.unreolved in the logs


Can you unchecked the conditional checkbook in the scheduled script and try again?


reeset
Kilo Contributor

Hi Edwin, I checked the system log and the search doesn't turn up anything.   I checked for incident.unresolved


I also looked manually.     Maybe I should delete what I have and try creating it all from scratch.   I don't know what I am doing wrong that it doesn't run, so frustrating.     If its not getting generated in the system log, does that mean the event isn't firing?