g_form.showFieldMsg and g_form.showErrorBox not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 10:03 PM
Hi Team,
I am unable to see the field message or error box under my variable, am i doing anything wrong.
- g_form.addErrorMessage('Please select a valid date. Start Date cannot be before today'); is executing and able to see the message at the top of the form.
- g_form.showFieldMsg & g_form.showErrorBox is not showing any message in both native and esc portal.
Thank You in advance,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 10:20 PM
Hi @Sriraj V
If the field is a variable (e.g., in a catalog item), ensure you’re using the correct variable name (e.g., variables.start_date instead of start_date) .
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 11:29 PM
Hi Ankur @Ankur Bawiskar ,
I made the required changes as per your suggestion. Still the issue exist.
Hello Rajesh @Rajesh Chopade1 - variable name is correct, i even used variables.start_date - Issue still exist.
Thank You,
Sriraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 04:37 AM
why are you using UI policy with script?
If you wish to use script then use onChange client script.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 05:32 AM
Hi Ankur @Ankur Bawiskar , I am doing a date validation for that particular variable and many threads suggested you use UI policy for date validation instead of on change client scripts. Thats why used UI policy.
So my UI policy condition is "start_date" before "today".
Then to clear value and showFieldMsg I used script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 05:34 AM
then in Execute if true - show the field message
in Execute if false - hide the field message and clear the value
what's not working?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader