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

Rajesh Chopade1
Mega Sage

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

Sriraj V
Tera Contributor

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

@Sriraj V 

why are you using UI policy with script?

If you wish to use script then use onChange client script.

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

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.

@Sriraj V 

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.

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