Business Rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 09:23 AM
when an incident is created, then a record should be created in a
problem table and any update in incident record should be updated in
the record created in problem table.(Using Business Rules)
I can able to create a problem when incident was created
but I want the info about how to update the fields of problem record ,if the incident was updated after its creation.
How to map all updated fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:16 AM
HI There,
Please refer below script which can be used in Script include.
(function executeRule(current, previous) {
// Check if this is an update and not a new incident
if (current && previous && current.sys_id === previous.sys_id) {
var problemGR = new GlideRecord('problem');
// Query the problem record associated with the current incident
problemGR.addQuery('incident', current.sys_id);
problemGR.query();
// Check if there is an associated problem record
if (problemGR.next()) {
// Update the problem record with the changes from the incident
if (current.short_description != previous.short_description) {
problemGR.short_description = current.short_description;
}
if (current.description != previous.description) {
problemGR.description = current.description;
}
// Add more fields to update as needed
// Update the problem record
problemGR.update();
}
}
})(current, previous);
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 11:15 AM
Query the problem record associated with the current incident
problemGR.addQuery('incident', current.sys_id);
problemGR.query();
I didnt under stand the above
how can we identify the problem record that belongs to this incident record
is there any inter linking field
can you please explain in detail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 11:26 AM
What is the relation between that incident and problem to query