g_form.showFieldMsg and g_form.showErrorBox not working.

Sriraj V
Tera Contributor

Hi Team,

I am unable to see the field message or error box under my variable, am i doing anything wrong.

  1. 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.
  2. g_form.showFieldMsg & g_form.showErrorBox is not showing any message in both native and esc portal. 

SrirajV_0-1737611901564.png

 

Thank You in advance,
Sri

13 REPLIES 13

@Sriraj V 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Juhi Poddar
Kilo Patron

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

 

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.

@Sriraj V 

  • 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