How to set Validation for end date in Record producer?

Deepika61
Tera Contributor

Hi All,

Actually i have a requirement that , i have two fields "start date and End date", basically if end user select end date 10 days below from the start date , then we need to show error message on submit, user selects 10 or more than 10 days from start date, then only need to submit request?

 

Please help me to solve this

 

Thanks

Deepika

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepika61 

did you try to use UI policy for this?

No Code date validations through (Catalog) UI Policies 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Abbas_5
Tera Sage
Tera Sage

Hello @Deepika61 ,

Please refer to the below link:
https://www.servicenow.com/community/hrsd-forum/i-want-to-add-validation-on-date-and-time-on-a-recor...

 

If it is helpful, mark it as a thumbs up!

Thanks & Regards,
Abbas

newhand
Mega Sage

@Deepika61 
"Catalog Client Scripts"  with  type "onSubmit"  !

for more information , refer here: Here 

 

 

Please mark my answer as correct and helpful based on Impact.

Vengateshwaran
Mega Guru

Hi @Deepika61 ,

I have a solution for your requirement refer to the code below:

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
       var sdt = new Date(g_form.getValue('u_start_date'));
    var edt =  new Date(g_form.getValue('u_end_date')) ;
    var duration = (edt.getDate()-sdt.getDate())+1;
    if(duration<10){
        g_form.addErrorMessage("Enter end date correctly");
        return false;
    }
}
 
Help others to find a correct solution by marking the appropriate response as correct answer and helpful.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepika61 

did you try to use UI policy for this?

No Code date validations through (Catalog) UI Policies 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader