Skip to content

Commit d142119

Browse files
authored
Create infomessage.js
1 parent 8155a28 commit d142119

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function onSubmit() {
2+
var changeType = g_form.getValue('type');
3+
var risk = g_form.getValue('risk');
4+
var state = g_form.getValue('state');
5+
var implementationPlan = g_form.getValue('implementation_plan');
6+
7+
// Validate mandatory field
8+
if (!implementationPlan) {
9+
g_form.addErrorMessage('Implementation plan is mandatory before submission.');
10+
return false;
11+
}
12+
13+
// Informational message when in planning state
14+
if (state == '-5') {
15+
g_form.addInfoMessage('Change is currently in planning. Please ensure risk assessment is complete.');
16+
}
17+
18+
// Display colour-coded messages based on risk
19+
switch (risk) {
20+
case '1':
21+
g_form.addErrorMessage('Critical Risk Change - Requires CAB and Director approval.');
22+
break;
23+
case '2':
24+
g_form.addHighMessage('High Risk Change - Requires CAB review.');
25+
break;
26+
case '3':
27+
g_form.addModerateMessage('Moderate Risk Change - CAB notification needed.');
28+
break;
29+
case '4':
30+
g_form.addLowMessage('Low Risk Change - Auto approval possible.');
31+
break;
32+
}
33+
34+
// Display success/info messages based on change type
35+
if (changeType == 'Emergency') {
36+
g_form.addSuccessMessage('Emergency Change - Proceed with immediate authorization.');
37+
} else {
38+
g_form.addInfoMessage('Standard Change - Follows the normal approval workflow.');
39+
}
40+
41+
return true;
42+
}

0 commit comments

Comments
 (0)