Date Formate for differ users causing issue while performing Date validations.

Rajyalakshmi
Tera Contributor

1.We need to validate date field value should be in 12 months range from current date.

2.In our ServiceNow instance we have different date formats  for few users.

3.Our date validation script is working fine for the users preference date format is YYYY-MM-DD .for other users who are having different date format for example yyyy/mm/dd or dd-mm-yyyy ,script getting failed.

4.Could you please suggest is there any global functionality is there to set date format in YYYY-MM-DD irrespective of user preference date format .

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Rajyalakshmi 

you should use UI policy so that date format is taken care of and you need not worry on it.

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

@Rajyalakshmi 

why not? UI policy can be created against any table and table's field.

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

8 REPLIES 8

JackieZhang
Tera Contributor

please share your code

OlaN
Giga Sage
Giga Sage

Hi,

It sounds like you are doing the comparison on the client side, with some form of client script ?

 

Instead, you can use the input from the user, send it into a script include and evaluate if the users selected date is within 12 months or not.

Ask if you would like me to explain in more detail.

VijayKumarDodde
Tera Expert

Always convert the date to a standard format (e.g., yyyy-MM-dd) in your script, regardless of the user preference.

Try passing date variable to script include and convert to yyyy-MM-dd format and compare.

Ankur Bawiskar
Tera Patron
Tera Patron

@Rajyalakshmi 

you should use UI policy so that date format is taken care of and you need not worry on it.

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