Re-open closed incident using Business rule ?

Yee Man Chun
Tera Expert

Hi all,

 

 

Is there a way to  use BR to re-open closed incident? I know it's not a  good practice to re-open the closed incidents mainly it will mess up the records. However, it's due to the company culture issue, we need to false and enable such re-open feature for closed incidents.

 

Do also let me know if there are any easiest way to do it.

6 REPLIES 6

Musab Rasheed
Tera Sage
Tera Sage

Hello,

It's not good thing to reopen closed Incidents, however simplest way to reopen Incident is through UI action, you can create UI action 'Reopen Closed Incident' and write simple code to change state value to work in progress. That's should be simple.

However as I said In begining it's not good to reopen closed incidents as it may mess up process like SLAs etc. What you can suggest there is already a functionality which is available OOB to reopen Incidents through UI action. What you can do is to keep incident state in Resolved for few days like 7 to 10 days then move state to Closed automatically through property or Scheduled job.

Remember not everything should be implemented, it is always better to practice what Servicenow recommends!

Here is link to OOB UI action:

https://instance/sys_ui_action.do?sys_id=d2d9d8110a0a3c7401bbadabed9b91db&sysparm_record_target=sys_...

Please hit like and mark my response as correct if that helps
Regards,
Musab

Pavankumar_1
Mega Patron

Hi @Yee Man Chun ,

As you know already it is not the best practice but if you still need to open the incidents which are closed.

Try below options.

 

Filter condition: Apply  filter as below right and copy query and use in script as encoded query.

Screenshot (196).png

 

Script: Below script you can use in background script to open closed incident's

 

var gr=new GlideRecord('incident');
gr.addEncodedQuery('state=7');//give copied query here you can apply filters as per your requirement
gr.query();
while(gr.next()){
gr.state='2'; //state value for Inprogress. Give your state value
gr.close_code='';
gr.close_notes='';
gr.closed_at='';
gr.closed_by ='';
gr.update();
}
 
Business rule Script: create After Business rule on Incident table  and check Update. On when to run tab give the conditions.
Check advanced field and use below script.
Script:
 

(function executeRule(current, previous /*null when async*/ ) {

current.state = '2'; //2 is for for In progress. Give your state value
current.close_code = '';
current.close_notes = '';
current.closed_at = '';
current.closed_by = '';
current.update();

})(current, previous);

 

 
If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Akhilesh Raghuw
Tera Expert

 if incident state changed to be Closed, reopen the incident ...

current.active = true;

gs.print("Incident reopened: " + current.number);

The condition is: current.incident_state != 7 ;

current.update(); //use at end

 

Pavankumar_1
Mega Patron

Hi @Yee Man Chun ,

have you checked my response ?

If not try and let me know if need anything

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar