Catalog item End date field

ashok17
Tera Contributor

In the catalog item there are two fields for date:

 

State date and End date

The requirement was End date cannot be more than one year from start date.

I want the End date to be maximum one year from start date.

 

Please help me how we will write client script for this requirement.

 

Thank You.

4 REPLIES 4

Sagar Pagar
Tera Patron

Hi @ashok17,

 

You can easily achieve using the Catalog UI policies with proper conditions.

Take a look at this article. It will help you.

No Code date validations through (Catalog) UI Policies 

 

Thanks,
Sagar Pagar

The world works with ServiceNow

Arun_S1
Tera Guru
Tera Guru

@ashok17 You can write a UI Policy which can validate if the End Date is within the one year form the start date as mentioned below.

end_date is more than 1 years after start_date as shown in the screenshot below.

 

Arun_S1_0-1688746823278.png

 

In the UI Policy action add an entry to clear the value of the end date.

Arun_S1_1-1688746942021.png

 

Also in the UI Policy add an alert message so the user will know why the date field is cleared.

Arun_S1_2-1688747027065.png

Result: Message is displayed when the end date is greater than one year and the end date is cleared.

 

Arun_S1_3-1688747070295.png

 

No Message displayed when the end date is within one year.

Arun_S1_4-1688747189153.png

Please mark the appropriate response as correct answer and helpful

 

 

ashok17
Tera Contributor

above solution not works for me in catalog item form

 

 

 

Please help me below requirement:

 

In the catalog item there are two fields for date:

 

State date and End date

The requirement was user can't choose End date filed more than one year from start date.

 

Please help me how we will write client script for this requirement.

 

Thank You.

@ashok17 You dont have to write a client script to validate the dates, it is possible through UI policies. Please follow the above steps and you should be able to achieve the same.

 

If you still wanted to write a client script, please tell me what you have written and i can help you in changing that to achieve the requirement.

 

Please mark the appropriate response as correct answer and helpful.

 

Thanks!!