- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2016 10:30 PM
I wants to display an sample error message from client side on the web page. So, I created following test page. But it's showing the error in browser console tab, "Uncaught ReferenceError: g_form is not defined".
Here is my page:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<input type="button" onclick="return validate();" value="Save"/>
</g:ui_form>
</j:jelly>
My client script:
function validate()
{
alert("Validating");
g_form.addErrorMessage('This is an error');
return false;
}
On click of the button, I am getting the alert message. But it's not displaying the error message on the form. What am I missing here?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2016 10:57 PM
Hi Ram,
Can you try something like this in your client script
- function validate()
- {
- var g_form=new GlideForm(); // I have added this
- alert("Validating");
- g_form.addErrorMessage('This is an error');
- return false;
- }
Thanks
Srini
Please mark this response as correct/helpful if it does so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2016 10:37 PM
Not sure that g_form is working on a ui page
take a look here. There is a couple of workarounds, but sadly you ain't alone...
g_form not initialized on a custom CMS page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2016 10:41 PM
Thank you,
Is there any alternative way in servicenow, we can display a message to user on client-side(apart from javascript alerts)??
Thanks
Rami Reddy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2016 10:57 PM
Hi Ram,
Can you try something like this in your client script
- function validate()
- {
- var g_form=new GlideForm(); // I have added this
- alert("Validating");
- g_form.addErrorMessage('This is an error');
- return false;
- }
Thanks
Srini
Please mark this response as correct/helpful if it does so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2016 11:00 PM
Thank you Srinivas,
Worked like charm..