Giving an error message on submit if any field remains empty on Catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2019 10:52 AM
I tried to write a script to display error message if any fields are empty on submitting catalog item.
function onSubmit() {
if( g_form.getDisplayBox('company').value ==" '' || g_form.getDisplayBox('size').value ==" '' )
{
g_form.addErrorMessage('Please select all the fields');
}
}
But when I test, the error message gets displayed and immediately the page goes to submission confirmation page before the error is resolved.
I want to display the error message and stay on the current page till the error is resolved. After resolving the error, when I try to submit it should go to submission confirmation page.
How can I achieve this criteria?
.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2019 10:57 AM
after your g_form.addErrorMessage add return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2019 12:10 PM
Hi Brian,
Thank you for the response. I have tried adding it.
Now, I am getting error message and I am able to stay on the current page.
But, I see that after resolving the error when I click on Order now button, it is not redirecting me to submission confirmation page. And also if the condition is false, item is not being able to submit.
I mean No Action is performed when I click on Order Now button in both the cases.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2019 12:44 PM
I have seen it happen a couple times this way but I was never able to figure out why. Try to add return true as an else.
if( g_form.getDisplayBox('company').value ==" '' || g_form.getDisplayBox('size').value ==" '' )
{
g_form.addErrorMessage('Please select all the fields');
return false;
}
else{
return true;
}
}
Another thought is if you want all filed will in why not just make them all mandatory?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2019 01:07 PM
I tried it. It's still not working.
Yeah that makes sense, even I thought the same but, in this story I am not supposed to use UI Policies. I will try using setMandatory method in the Script.
Thanks.