Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

ShowFieldMsg in UI policies

servicenow14710
Tera Expert

Hello developers, I need to show field msg for a date field via ui polices on service portal, but the message is not displayed. Any suggestions is appreciated. Thanks!

9 REPLIES 9

Hi @servicenow14710 
I have tried and it's working for me, please try to replicate 

_Gaurav_0-1709712446165.png_Gaurav_1-1709712467243.png


Please mark this as helpful and accept it as a solution if this works for you.
Thanks!

Hi @servicenow14710 
If this response helped you to achieve your requirement, please accept it as a solution.
Thanks!

@servicenow14710  

 

use this below Code in UI Policy Script 

Execute if true:
g_form.clearValue('fieldname');
g_form.showErrorBox('fieldname', your message):


Execute if false 
g_form.clearMessages(); // clears messages if condition is false 

 

 

Regards,

Shyamkumar 

 

 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Umesh Dubal 171
Tera Contributor

hi @servicenow14710 
I have worked on it I am sharing the screenshots with you hope it helps you

UmeshDubal171_0-1709713413046.png

UmeshDubal171_3-1709713477421.pngUmeshDubal171_4-1709713484998.png

 

Parth_Poriya
Tera Expert

Hi 

You need to write script on catalog client script 

g_form.showFieldMsg('variable_name','msg','error');