Non-Major problem record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 07:58 PM
need to add work notes and close the problem tasks automatically when problem record is moved to closed.
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 08:11 PM
Write a simple BR to achieve this requirement.
- Go to System Definition > Business Rules.
- Click "New" to create a new business rule.
- Name: Give it a descriptive name (e.g., "Close Problem Task on Problem Closure").
- Table: Select "problem".
- When to Run: Select "After".
Code Snippet:-
(function executeRule(current, previous /*null when async*/) {
// Check if the problem state has changed to "Closed"
if (current.state == 3 && previous.state != 3) { // 3 is the ID for the "Closed" state in ServiceNow
// Get the related problem task(s)
var problemTask = new GlideRecord('problem_task');
problemTask.addQuery('problem', current.sys_id);
problemTask.query();
while (problemTask.next()) {
// Add a work note to the problem task
var note = "Problem Task " + problemTask.number + " has been closed as part of problem " + current.number + " closure.";
problemTask.work_notes = note;
problemTask.update();
// Close the problem task
problemTask.state = 3; // 3 is the ID for the "Closed" state in ServiceNow
problemTask.close_code = "Resolved"; // Or appropriate close code
problemTask.update();
}
}
})(current, previous);
Mark it helpful and Accept Solution, If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 08:40 PM
Actually this script is for Scheduled job Need to add work notes automatically in problem record and problem task as well and close the problem tasks automatically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 10:08 PM
if you want to have scheduled job then which problems should be closed? open?
what script did you start with and where are you stuck?
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-07-2025 11:40 PM - edited ‎03-08-2025 12:43 AM
Below one existing script is for Non-Major problem record in the new state that reaches 29 days is automatically closed.