- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 01:36 AM
Hi folks,
Looks like I have issue in my on submit script and I cannot find the solution for now.
So I have catalog item form in portal(request form). The goal is to display an alert and block submit if in case specific values are selected. In my example, if in multiple choice field called "severity" user picks option "information" and in next field they select in ''first_line'' support one specific sys id, it should show alert as in my code and + block submit.
function onSubmit() {
(function() {
var specificGroupSysID = '1911367437e72200d540d0d543990e1d'; // specific assignment group sys ID
var severityLevel = 'Information'; // Severity level
g_form.OnSubmit(function() {
var selectedGroup = g_form.getValue('first_line');
var selectedSeverity = g_form.getValue('severity');
// Check if the selected group matches the specific sys ID and severity level is Information
if (selectedGroup == specificGroupSysID && selectedSeverity == severityLevel) {
// Show an alert
alert('You cannot send "info" severity alert to this first line assignment group.');
// Cancel the submission
g_form.setAbortAction(true);
}
});
})();
}
Do you see where i have error? or can you show how to make this script more efficient if its possible?
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 01:48 AM
Hi @Julius28 here is the updated script
function onSubmit() {
var specificGroupSysID = '1911367437e72200d540d0d543990e1d'; // specific assignment group sys ID
var severityLevel = 'Information'; // Severity level
var selectedGroup = g_form.getValue('first_line');
var selectedSeverity = g_form.getValue('severity');
// Check if the selected group matches the specific sys ID and severity level is Information
if (selectedGroup == specificGroupSysID && selectedSeverity == severityLevel) {
// Show an alert
alert('You cannot send "info" severity alert to this first line assignment group.');
// Cancel the submission
return false;
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 01:52 AM
Thank you @Harish KM this worked out well. Thank you @Robin Hogli for taking look as well.