Get current date on a Catalog Client Script, and compare it with Variable date field?

xhensilahad
Tera Expert

Hi,

What is the easiest way to achieve the following in a Catalog Client Script

1) Get current date time

2) Compare it with Date Input Variable

 

If Input Variable before today's date, then Show a field message.

 

Thank you in advance for all your answers.

1 ACCEPTED SOLUTION

Looks like its expected. 

Data validation showFieldMsg not working in Service Portal - Known Error (servicenow.com)

 

The workaround is to use clearValue before showFieldMsg if you want the message to persist.

 

 

-Anurag

View solution in original post

9 REPLIES 9

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can write a Catalog ui policy as below and inthe script part write the show error

AnuragTripathi_0-1729775527946.png

 

g_form.showFieldMsg('column_name','Your message','error');

 

-Anurag

Hi Anurag,

How can I clear the value please ?

When I add both scripts, the 'g_form.clearValue', disables the 'g_form.showFieldMsg'.

 

Thank you

You can add a ui policy action on the same and add Clear Value.

-Anurag

Hi, 

Thank you for your answer.

I have tried that but the Value is cleared and I do not see the error message.

I changed the orders, but still the same...