Write a bussiness rule when incident is closed then associated problem will be closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 09:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 11:34 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 08:53 PM
Hi @S Kuanar
There seems to be a misunderstanding in your requirement. Typically, multiple Incidents are linked to a Problem, and the Problem remains open until the Root Cause Analysis (RCA) is completed and the issue is resolved. It wouldn’t make sense to automatically close a Problem just because an Incident is resolved.
Additionally, your script won't work due to this line:
inc.addQuery('incident', current.sys_id);
The Problem [problem] table does not have the incident field. The relationship works the other way around, each Incident can reference a Problem through the problem_id field. => 1 problem and multiple incidents
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 09:13 PM - edited 03-06-2025 09:21 PM
Hello @S Kuanar
Four Mandatory fields values of problem table/form were missing, hence modified your code:
var inc = new GlideRecord('problem');
inc.addQuery('incident', current.sys_id); //considering you have incident column name/field in the problem table/form else ('sys_id', current.problem_id) will work too.
inc.addQuery('state', '!=', 107);
inc.query();
while (inc.next()) {
inc.cause_notes = 'Test1';
inc.close_notes = 'Test2'; // can be equivalent to current.close_notes
inc.fix_notes = 'Test3';
inc.resolution_code = 'fix_applied'; // only 4 choices are available oob
inc.state = 107;
//inc.close_notes='close';
inc.update();
}
Now, if above is for learning purpose then it is okay. You might have also learnt that missing fields added above are really relevant to capture detailed information before closing the problem.
So, if you are given such requirement then have a brainstorming session with your peers as well as your stakeholders that problem are open to identify the underlying root cause, capture the costs associated with this problem and a solution to avoid such in future.
Hope that helps!
Hope that helps!