how to use UI policy for date validation and clear that multiple field for catalog form

rahul16
Giga Guru

rahul16_0-1664802081580.png

I created a UI policy where we take dates from the form.

rahul16_1-1664802115366.png

How to write a script that

 

  1. if the user enters past dates then clear the selected field.(if user select start_date wrong then clear that field only not the other and same for the start_end date too)
  2. if the user enters the date_start and date_end if the date_end is less than date_start then clear the date_end field.

how to achieve this with one UI policy.

I created a UI policy for all date validation conditions but I can't clear the selected field if the user selects the wrong date.

rahul16_2-1664802388150.png

This is the catalog form date 1 is date_Start and date 2 is date_end.

 

5 REPLIES 5

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please follow the  article "https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-..." you should be able to achieve your requirement

 

Please mark answer correct/helpful based on Impact.

 

yes, I followed that article only my problem is how to achieve these steps. 

  1. if the user enters past dates and then clears the selected field.
  2. if the user enters the date_start and date_end if the date_end is less than date_start then clear the date_end field.

I see then you will have to move the conditions inside the run script.

 

I see two ways to proceed from here:-

If you want to keep the condition in the filter itself either you clear both the values in case of any one condition fails

 

OR

 

You move the condition in the run script and use a if else.

 

Please mark answer correct/helpful based on Impact.

rahul16_0-1664807656758.png

I created the script but not working as excepted can you please check