- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:50 AM
Hello,
I'm having issues with my onSubmit catalog client scripts. I creates 2 scripts that will check if urgency or impact is selected, it will stop the submit. After changing and trying to submit, it does nothing when i try to submit. Here is one of the script below. They are the same except for the variable name. Please assist if you can.
function onSubmit() {
g_form.getValue('please_indicate_the_urgency_of_this_outage');
if (g_form.getValue('please_indicate_the_urgency_of_this_outage') == '3');
g_form.addErrorMessage("Please submit the Create Incident form if urgency is Lower Priority");
return false;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 08:11 AM
Hi @KB30
Can you set UI Type to all and try the following script-
function onSubmit() {
if (g_form.getValue('please_indicate_the_urgency_of_this_outage') == '3') {
g_form.addErrorMessage("Please submit the Create Incident form if urgency is Lower Priority");
return false;
}
return true;
}
It should do.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 07:17 PM - edited 02-14-2024 07:22 PM
Hi @KB30 ,
Before the If statement, please add below line of code, select the valid value and submit to see if it is '3'? Or what value?
alert(g_form.getValue('please_indicate_the_urgency_of_this_outage'))
Also are you creating 2 client scripts for this case? If yes then please keep only 1 script, it is enough to meet your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 07:26 PM
Hi @KB30
May be the other On-Submit Client Script is throwing the error message. Have you checked that as well ?
Also, why you need to have two On-Submit client scripts when the validation could be done in a single On-Submit Client Script itself ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 07:25 AM
Hey @Amit Verma I believe I had one of them disable, but I'll test again. I'll try to combine into one. Do I just stack the script after the first completes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 08:00 AM
@Amit Verma I tried again with one disabled and I still get the same issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 07:27 PM
Please try below code
function onSubmit() {
var urgencyValue = g_form.getValue('please_indicate_the_urgency_of_this_outage');
if (urgencyValue == '3') {
g_form.addErrorMessage("Please submit the Create Incident form if urgency is Lower Priority");
return false;
}
// Continue with submission if the condition is not met
return true;
}
Kindly mark helpful/accepted if it helps you.