How to change the priority based on another tables priority
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 11:51 AM
I need to update the priority and impact when a location is added or changed on an incident. The task is to use the default priority from the location to set the impact on the Incident form
and when a Service or Service Offering is added or changed on an incident, use the default priority on the CI record to set the urgency on the Incident form. how can this be achieved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 10:40 AM
Hi @DevtoSME You need to create two business rules. have a look at below steps and update script accordingly
Business Rule for Location Changes
- Table: incident
- When to run: Before (to ensure the impact is set before the record is saved)
- Insert: Checked (if you want it to apply when a new record is created)
- Update: Checked (to apply when an existing record is updated)
Add below script
(function executeRule(current, previous /*null when async*/) {
if (current.location.changes()) {
var location = new GlideRecord('cmn_location');
if (location.get(current.location)) {
var defaultPriority = location.default_priority;
current.impact = defaultPriority;
}
}
})(current, previous);
Business Rule for Service/Service Offering Changes:
- Table: incident
- When to run: Before
- Insert: Checked
- Update: Checked
Add below script :
(function executeRule(current, previous /*null when async*/) {
if (current.service.changes() || current.service_offering.changes()) {
var ci = new GlideRecord('cmdb_ci');
if (ci.get(current.service)) {
var defaultPriority = ci.default_priority;
current.urgency = defaultPriority;
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 02:17 PM
Hi so i was advised it would need to be a onload client script so the end user can see the change of impact and urgency. do you have suggestion of how that would look instead of a BR?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 10:54 PM
Hi @DevtoSME ,
Am sorry but How it can be a onload script, when the change is happening at the database level ?
Business rule is the best suited and @Sid_Takali has already provided you with script to be tested.