How to write a client script to hide fields from form if created after today date serviceNow?

Community Alums
Not applicable

Hi All,

I want to hide field from for if created after today how to write a client script for this?

Thanks in Advance,

Prachi

9 REPLIES 9

Does "today" imply a fixed date such as "March 21, 2022" of or "today" as when the form is opened?

If it's the time when the form is opened and field "Created" is of type Date, set the condition to "Created" "after" "today" as I've done in my earlier response.

Hi Prachi,

Don't select the calendar icon. Select the "v" drop-down and select "Today". 

The condition should be "Created", "before", "Today" because "Created" will be the date when the record was created. That is, if today's date if after the date when the record was created, then hide the field.

Note, that field "Created" is automatically set by ServiceNow to the date when the record is created. As such, it's not possible to "create" a record in the future date.

find_real_file.png

find_real_file.png

Execution results:

case 1: record created today. Field "Field to hide" is visible.

find_real_file.png

case 2: record created in the pase. Field "Field is hide" is not displayed.

find_real_file.png

"but its not working"

So what's not working? You are not sharing anything or asking for help on what's not working?

Anyway, here you go, proven mechanism:
- 2019-08-12 No Code date validations thru (Catalog) UI Policies

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Aman Kumar S
Kilo Patron

This can be achieved by UI policy as well:

Condition can be:

Created - after - today

Add ui policy action for the field

Best Regards
Aman Kumar

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Any follow-up needed? Or was my answer sufficient?
Let me know.

If your question is solved, please close the topic by marking my answer as correct. This will help others searching for a similar question and will remove the topic from the unsolved list.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn