- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-04-2023 03:39 AM
Update the incident work notes and changes the state to back to Work in progress of the incident when the Change Request is created from Incident. How to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-04-2023 04:05 AM
You can create a Before Update business rule like the one below on Incident table.
(function executeRule(current, previous /*null when async*/) {
current.work_notes = "Change " + current.getDisplayValue('rfc') + ' create from this incident.';
current.state = 2;
})(current, previous);
Please mark my answer helpful and accept as a solution if it helped šāļø
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-04-2023 03:54 AM
so what script did you try so far and what's not working?
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-04-2023 03:57 AM
Hi
(function executeRule(current, previous /*, /* when */) {
// Check if the change is created from an incident
if (current.incident && current.incident != '') {
var incidentGR = new GlideRecord('incident');
if (incidentGR.get(current.incident)) {
// Update work notes
incidentGR.work_notes = 'Change created: ' + current.number;
incidentGR.update();
// Change incident state back to "Work in Progress"
incidentGR.state = 2; // Assuming 2 represents "Work in Progress"
incidentGR.update();
}
}
})(current, previous);
I tried this BR but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-04-2023 04:07 AM
The above BR is written as After/Before and on which table
small update in script -> don't use update() 2 times
(function executeRule(current, previous /*, /* when */) {
// Check if the change is created from an incident
if (current.incident && current.incident != '') {
var incidentGR = new GlideRecord('incident');
if (incidentGR.get(current.incident)) {
// Update work notes
incidentGR.work_notes = 'Change created: ' + current.number;
// Change incident state back to "Work in Progress"
incidentGR.state = 2; // Assuming 2 represents "Work in Progress"
incidentGR.update();
}
}
})(current, previous);
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-04-2023 04:05 AM
You can create a Before Update business rule like the one below on Incident table.
(function executeRule(current, previous /*null when async*/) {
current.work_notes = "Change " + current.getDisplayValue('rfc') + ' create from this incident.';
current.state = 2;
})(current, previous);
Please mark my answer helpful and accept as a solution if it helped šāļø
Anvesh