Only past dates on catalog date variable

Yasin Shaik11
Tera Contributor

Hi All,

 

On a catalog date variable i want to allow only past dates not today date or future date. how we can do using the UI polices. 

1 ACCEPTED SOLUTION

Hi @Yasin Shaik11 ,

 

Uncheck the Onload checkbox from UI policy & the script u should write in false condition. After making this changes please check it will work.

 

Thanks,

Danish

 

View solution in original post

12 REPLIES 12

Oke, but your condition is now actually on before today, so past dates. Can you try changing that?

And please also share what is in your script.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Can you please tell me what condition should i mention there? for only past dates allow  

 

If true 

function onCondition() {

    alert('please select past dates');
    g_form.clearValue('past_date_only');

}

@Mark Roethof 

we don't have the on before today in the condition builder. can you check from your side as well.   

Hi @Yasin Shaik11 ,

 

Uncheck the Onload checkbox from UI policy & the script u should write in false condition. After making this changes please check it will work.

 

Thanks,

Danish

 

Danish Bhairag2
Tera Sage

Hi @Yasin Shaik11 ,

 

You can create a UI policy with condition date - before - today.

Then go to the script tab in UI policy & check run scripts & make sure u make Run scripts in UI type as ALL. & paste below script.

 

DanishBhairag2_0-1705904820270.png

 

function onCondition() {
alert('Only past dates can be selected');
g_form.clearValue('date');
}

 

Thanks,

Danish