- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 07:28 AM
Hello ,
I am looking to edit a business rule that currently runs when the Incident state is changed to "Resolved" the Case state changes to "Work In Progress".
I want to add an exception into the script that if the Incident state is changed to resolved and the Case state is already "Resolved" then the Case state does not change to "Work In Progress"
the current script in the business rule is below :
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 07:37 AM
Hello,
If you are suing OOB state values in case then the below code will do the trick for you:-
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var caseGr = new GlideRecord("sn_customerservice_case");
caseGr.addEncodedQuery('state!=6'); //Added this line to exclude resolved cases
caseGr.addQuery("incident",current.sys_id);
caseGr.addActiveQuery();
caseGr.query();
while(caseGr.next())
{
caseGr.close_notes = current.close_notes;
caseGr.u_symptom = current.u_symptom;
caseGr.resolution_code = current.close_code;
caseGr.u_cause = current.u_cause;
caseGr.state = 2;
caseGr.update();
}
})(current, previous);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 07:37 AM
Hello,
If you are suing OOB state values in case then the below code will do the trick for you:-
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var caseGr = new GlideRecord("sn_customerservice_case");
caseGr.addEncodedQuery('state!=6'); //Added this line to exclude resolved cases
caseGr.addQuery("incident",current.sys_id);
caseGr.addActiveQuery();
caseGr.query();
while(caseGr.next())
{
caseGr.close_notes = current.close_notes;
caseGr.u_symptom = current.u_symptom;
caseGr.resolution_code = current.close_code;
caseGr.u_cause = current.u_cause;
caseGr.state = 2;
caseGr.update();
}
})(current, previous);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 08:23 AM
Hello,
If my answer helped you please mark it as correct.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 08:28 AM
Thanks - works a treat.