Mark Roethof
Tera Patron
Tera Patron

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

 

Hi there,

 

Client Side date validations, o man, they can be a real pain in the but! Getting the right format, different language settings, timezones, etc.. And then working with Scoped Apps… some GlideDate functions not being available. If you look at the community posts, a lot of situations like these are posted. Scripting not working, applying GlideAjax, splitting dates, etc.. So to share some gained knowledge and experience:

 

There's a much easier way!

 

Using the No Code condition builder on (Catalog) UI Policies! Only Low Code needed for an info/error message to display to the user, maybe clearing the field/variable value, etc..

Examples

How to setup checking if…

An entered date for a Variable is in the past. If so, clear the variable value and give the User an error message.

find_real_file.png

find_real_file.png

find_real_file.png

An entered date for a Field is after 7 days in the future. If so, clear the field value and give the User a field message.

find_real_file.png

find_real_file.png

find_real_file.png

Comparing two entered dates with each other. Date 2 should not be before Date 1 (image, planned end date should not be before planned start date)

find_real_file.png

As you can see in the examples above, Low Code for the follow-up on your validation and the actual validating simply through the condition builder within a (Catalog) UI Policy.
---

 

And that's it actually. Not much to it. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Paphos Group
---

LinkedIn

Comments
MalikB
Tera Contributor

how to do it with the client script

Mark Roethof
Tera Patron
Tera Patron

@MalikB if you search a little bit on the Community, you will see that question has been answered hundreds of times.

Manthan98
Tera Contributor

Hello @Mark Roethof 
Thank you for this solution. I have the exact same requirement.
If start date and end dates are less than 180 days apart, I should hide an option from another select box variable on the form.
I am using Catalog UI policy conditions and the Catalog UI policy script( g_form.removeOption() ) to achieve this. This UI policy does not contain any actions.

May I know pros and cons of this approach over a client script (GlideAjax, script include etc etc)?

Is this approach better than client script considering best practices, system performance etc?

Many Thanks In Advance
Manthan

AmolJ
Tera Expert

ServiceNow Workspace has really made it so hard to do anything. This does not work on CSM workspace at all... Absolute pain in the neck.

Version history
Last update:
‎07-21-2024 01:15 AM
Updated by:
Contributors