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-24-2025 12:55 AM
Hope you are doing good.
Did my reply answer your question?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 11:53 PM
Hello @Sriraj V
You are clearing the value for start_date variable and that's why the field message or error box disappears.
Instead add clearValue in execute if false block.
Here is the updated script:
Execute if true:
function onCondition() {
g_form.addErrorMessage('Please select a valid date. Start Date cannot be before today');
g_form.showFieldMsg('start_date', 'Please select a valid date. Start Date cannot be before today', 'error',
true);
}
Execute if false:
function onCondition() {
g_form.clearValue('start_date');
g_form.hideFieldMsg('start_date',true);
}
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 03:32 AM
Hi Juhi @Juhi Poddar , Thanks for the reply. This solution didn't worked and when we keep clearValue in "Execute if False", value is not clearing when condition satisfied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 03:52 AM
- If the condition is met you see the field message.
- When clearing a value, automatically the condition will not meet as it is empty and therefore you cannot see the field message.
- You can update and add the condition like if the field is empty you see the field message. The limitation here is you will see the message even if you haven't selected any date.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar