- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-12-2020 02:45 PM
Dear Experts,
can someone help me with below situation/script for the same.
we have one choice field on change form with Yes/No options , we are looking this to set to "Yes" if someone relates record i.e incident(one or more) in "Incidents Caused By Change" tab on change form and sets to "No" if there is no record or someone removes the records from this tab.
Thanks
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-13-2020 12:31 AM
you can achieve above functionality by writing after business rule on "Incident" table.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if (current.caused_by) {
var gr_chg = new GlideRecord('change_request');
gr_chg.addQuery('sys_id', current.caused_by);
gr_chg.query();
while (gr_chg.next()) {
// add code here to process the incident record
gr_chg.u_boolean_1 = true;
gr_chg.update();
}
}
if (previous.caused_by) {
var gr_inc = new GlideRecord('incident');
gr_inc.addQuery('caused_by', previous.caused_by);
gr_inc.query();
var gr_chg1 = new GlideRecord('change_request');
gr_chg1.addQuery('sys_id', previous.caused_by);
gr_chg1.query();
if (gr_inc.getRowCount() > 0) {
// add code here to process the incident record
gr_chg1.u_boolean_1 = true;
gr_chg1.update();
} else {
while (gr_chg1.next()) {
gr_chg1.u_boolean_1 = false;
gr_chg1.update();
}
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-12-2020 10:58 PM
you can achieve above functionality by writing business rule on "Incident" table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-12-2020 11:33 PM
Hi Adi,
Thanks for the response.
but i dont see any field with name "on_change" on incident form.
Do you mean "caused_by"(caused by change)..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-13-2020 12:31 AM
you can achieve above functionality by writing after business rule on "Incident" table.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if (current.caused_by) {
var gr_chg = new GlideRecord('change_request');
gr_chg.addQuery('sys_id', current.caused_by);
gr_chg.query();
while (gr_chg.next()) {
// add code here to process the incident record
gr_chg.u_boolean_1 = true;
gr_chg.update();
}
}
if (previous.caused_by) {
var gr_inc = new GlideRecord('incident');
gr_inc.addQuery('caused_by', previous.caused_by);
gr_inc.query();
var gr_chg1 = new GlideRecord('change_request');
gr_chg1.addQuery('sys_id', previous.caused_by);
gr_chg1.query();
if (gr_inc.getRowCount() > 0) {
// add code here to process the incident record
gr_chg1.u_boolean_1 = true;
gr_chg1.update();
} else {
while (gr_chg1.next()) {
gr_chg1.u_boolean_1 = false;
gr_chg1.update();
}
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-18-2020 02:50 PM
Hi Adi,
It Works , Thank you very much !