- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2023 02:22 AM
Hi Community, I have written a BR to change state of related incidents to resolved when problem is resolved and to copy the fix notes field from problem to resolution notes in associated incidents. But it is not working can anyone please give the solution for this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2023 04:23 AM
Hi @SanthoshKumar R,
Try this updated scripts and your business rule condition should state changes to resolved:
(function executeRule(current, previous /*null when async*/ ) {
var problem = current.getUniqueValue();
var inc = new GlideRecord('incident');
inc.addQuery('problem_id', problem);
inc.query();
while (inc.next()) {
inc.setValue('state', '6');
inc.setValue('close_notes', current.description);
inc.setValue('close_code', 'Resolved by problem: ' + current.number);
inc.setWorkflow(false);
inc.autoSysFields(false);
inc.update();
}
})(current, previous);
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2023 03:55 AM
@SanthoshKumar R can you please share the BR conditions and the script here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2023 04:12 AM
BR to change state of related incidents to resolved when problem is resolved and to copy the fix notes field from problem to resolution notes in associated incidents.
as per you guidence I tried another field but it is creating new incident with updated data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2023 04:23 AM
Hi @SanthoshKumar R,
Try this updated scripts and your business rule condition should state changes to resolved:
(function executeRule(current, previous /*null when async*/ ) {
var problem = current.getUniqueValue();
var inc = new GlideRecord('incident');
inc.addQuery('problem_id', problem);
inc.query();
while (inc.next()) {
inc.setValue('state', '6');
inc.setValue('close_notes', current.description);
inc.setValue('close_code', 'Resolved by problem: ' + current.number);
inc.setWorkflow(false);
inc.autoSysFields(false);
inc.update();
}
})(current, previous);
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar