problem ticket should not be closed when related incident(s) are open

Venky Kshatriy2
Tera Contributor

Experts,

Could you please guide me how can I achieve below requirement.

 

Problem ticket should not be closed when any of the related incidents are still in Open state.

And the problem form submission action should be restricted showing the Info Message.

 

Please guide me 

Thanks in advance.

2 REPLIES 2

Amit Gujarathi
Giga Sage
Giga Sage

HI @Venky Kshatriy2 ,
I trust you are doing great.Create a Business Rule in ServiceNow to prevent problem ticket closure when related incidents are open:

  • Navigate to the "Business Rules" module in ServiceNow.
  • Click on "New" to create a new business rule.
  • Provide a name for the rule, such as "Prevent Closure of Problem Tickets with Open Incidents."
  • Set the "Table" field to "Problem [problem]" to apply the rule to problem tickets.
  • In the "Advanced" section, write the following script to check for open related incidents and prevent closure:

 

 

 

(function executeRule(current, previous) {
  // Query for open incidents related to the problem ticket
  var incidentGr = new GlideRecord('incident');
  incidentGr.addQuery('problem_id', current.sys_id);
  incidentGr.addQuery('state', 'IN', '1,2,3'); // Open states: New, In Progress, On Hold
  incidentGr.query();

  // If any open incidents are found, prevent the problem ticket closure
  if (incidentGr.hasNext()) {
    current.setAbortAction(true);
    gs.addInfoMessage('Cannot close the problem ticket as there are still open incidents related to it.');
  }
})(current, previous);

 

  1. Modify the Problem form to display an info message and restrict form submission:
    • Navigate to the "Form Layouts" module in ServiceNow.
    • Locate the form layout used for the Problem table and open it for editing.
    • Add a new UI Macro element to the form layout.
    • Set the "Macro Name" field to "InfoMessage" to display an info message.
    • In the "Message" field of the UI Macro, enter the following text: "Form submission for problem tickets is restricted. Please review and resolve any open incidents before proceeding."
    • Save the form layout changes.

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



@Amit Gujarathi  - This would still change the state on the UI, any solution for that?

KaranChhabra6_1-1686737682145.png

 

Thanks!