Assigned_to is inactive, make the assigned to as blank for Open Tickets

atul_05
Tera Contributor

If the Assigned to is Inactive, then make the assigned to as blank.

Need this for all the Open Active tickets including Incidents, tasks, Problem, RITM's

 

Can you please help me achieve this. Do we have to create a Flow or it can be done using BR.

Please provide the Flow or the script for this.

 

1 ACCEPTED SOLUTION

@atul_05 Then you can create this as a scheduled job and run on a daily basis. This way the ticket will get updated on a daily basis. 

 

Here is the filter I created for the script on the task table.

 

Screenshot 2024-07-09 at 4.19.12 PM.png

 

Here is the script I wrote to fix the records.

 

var glideTask = new GlideRecord('task');
glideTask.addEncodedQuery('active=true^sys_class_name=problem^ORsys_class_name=incident^ORsys_class_name=sc_task^ORsys_class_name=sc_req_item^assigned_to.active=false');
glideTask.query();
while(glideTask.next()){
	glideTask.setValue('assigned_to','');
	glideTask.update();
}

 

You can put this script inside a fix script or a scheduled job.

 

Please make sure to test this script on a non prod instance first, verify the result and then run it on a prod instance.

 

Please mark the response helpful and accepted solution if it managed to address your question.

View solution in original post

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@atul_05 You can achieve this via a Fix script/Background script. Let me know if you need any help in creating the script.

Hi @Sandeep Rajput 

 

I want this to run every time and check for any Open tickets in the future as well. 

@atul_05 Then you can create this as a scheduled job and run on a daily basis. This way the ticket will get updated on a daily basis. 

 

Here is the filter I created for the script on the task table.

 

Screenshot 2024-07-09 at 4.19.12 PM.png

 

Here is the script I wrote to fix the records.

 

var glideTask = new GlideRecord('task');
glideTask.addEncodedQuery('active=true^sys_class_name=problem^ORsys_class_name=incident^ORsys_class_name=sc_task^ORsys_class_name=sc_req_item^assigned_to.active=false');
glideTask.query();
while(glideTask.next()){
	glideTask.setValue('assigned_to','');
	glideTask.update();
}

 

You can put this script inside a fix script or a scheduled job.

 

Please make sure to test this script on a non prod instance first, verify the result and then run it on a prod instance.

 

Please mark the response helpful and accepted solution if it managed to address your question.

atul_05
Tera Contributor

Hello @Sandeep Rajput 

 

Can you please elaborate more on how to create the scheduled job. I have created the filters that you have shown but under scheduled jobs, it asks for what would you like to automate? 

Which one we have to select from below?

  1. Automate the generation and distribution of a report
  2. Automatically generate something (a change, an incident, a ci, etc) from a template
  3. Automatically run a script of your choosing
  4. Automatically run a script to create a report summary table
  5. Automate the generation and distribution of a custom chart

 

Also, will this run automatically or we have to run this manually every day.