Skip to content

Commit 0b3050c

Browse files
authored
Create script.js
1 parent 8bae41c commit 0b3050c

File tree

1 file changed

+30
-0
lines changed
  • Client-Side Components/Client Scripts/Abort direct incident closure without Resolve State

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
// Prevent execution during form load or when value is empty
3+
if (isLoading || newValue === '') {
4+
return;
5+
}
6+
7+
// Dummy values for state comparison
8+
// Assuming:
9+
// 6 = Resolved
10+
// 7 = Closed Complete
11+
var RESOLVED = 6;
12+
var CLOSED = 7;
13+
14+
// Prevent direct move to Closed without passing through Resolved
15+
if (newValue == CLOSED && oldValue != RESOLVED) {
16+
17+
// Reset to previous state
18+
g_form.setValue('state', oldValue);
19+
20+
// Show validation warning
21+
g_form.addErrorMessage(
22+
'Direct closure is not allowed. Please first move the incident to Resolved state.'
23+
);
24+
25+
// Reload page after showing error
26+
setTimeout(function() {
27+
location.reload();
28+
}, 3000);
29+
}
30+
}

0 commit comments

Comments
 (0)