- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 08:35 AM
When the state of incident is changed to on hold with reason as Awaiting problem, check if there is already an existing problem with that incident, if not please create a new problem with similar details as incident.
How it can be achieve by using business rule.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 08:27 PM
Do this. ensure you use correct state values in BR condition
Create a Business Rule:
Table: incident
When to run: before update
Condition: current.state == 3 && current.hold_reason == 3
Script:
(function executeRule(current, previous /*null when async*/) {
// Check if there is already an existing problem linked to this incident
if (!current.problem_id) {
// Create a new Problem record
var problem = new GlideRecord('problem');
problem.initialize();
problem.short_description = current.short_description;
problem.description = current.description;
problem.insert();
// Link the newly created problem to the incident
current.problem_id = problem.sys_id;
}
})(current, previous);
This script checks if there is an existing problem linked to the incident. If not, it creates a new problem with similar details and links it to the incident.
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
12-31-2024 08:27 PM
Do this. ensure you use correct state values in BR condition
Create a Business Rule:
Table: incident
When to run: before update
Condition: current.state == 3 && current.hold_reason == 3
Script:
(function executeRule(current, previous /*null when async*/) {
// Check if there is already an existing problem linked to this incident
if (!current.problem_id) {
// Create a new Problem record
var problem = new GlideRecord('problem');
problem.initialize();
problem.short_description = current.short_description;
problem.description = current.description;
problem.insert();
// Link the newly created problem to the incident
current.problem_id = problem.sys_id;
}
})(current, previous);
This script checks if there is an existing problem linked to the incident. If not, it creates a new problem with similar details and links it to the incident.
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
