Retro Change date must be in the past

Riaz3
Giga Expert

Hello,

We have a problem where users are creating Retro Changes with a future date.

What I need is an On Change Client Script which prevents the user from entering a date in the future if the change it Retrospective.

Ideally, the date must be in the past by at least 1 hour, if that is not possible then any past date must be entered the planned_start field and the end field if the change Retrospective.

Can anyone help?

Many Thanks

5 REPLIES 5

Priyanka Teke1
Mega Sage

Hello Riaz,

 

You can try below script..

 

function onChange(control, oldValue, newValue, isLoading) {  

 

if(isLoading || newValue == '') {  

 

return;  

 

}  

 

var date = new Date();  

 

var dateEntered= new Date(getDateFromFormat(g_form.getValue('end_date'),g_user_date_time_format));  

 

if (dateEntered< date) {  

 

 

alert("Date Cannot be in past");

}  

Hi Priyanka,

Thank you, however, what I had written was "prevents the user from entering a date in the future" so basically it MUST be a past date.

Any it should only check the Start Date field.

I have seen the above script you have pasted in another thread and it does not work for me.

Thanks,

Riaz

 

 

AbhishekGardade
Giga Sage

Hello Riaz,

Why Client script? you can achieve that using UI policy

Check this article,

https://community.servicenow.com/community?id=community_article&sys_id=f61964aadbcb3fc85129a851ca961...

Please mark as Correct Answer/Helpful, if applicable.
Thanks! 
Abhishek Gardade

Thank you,
Abhishek Gardade

Hello Riaz,

Any update on this?


If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you, Abhishek

Thank you,
Abhishek Gardade