How to write a client script to hide fields from form if created after today date serviceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 08:07 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 08:10 AM
Hi there,
What's the reason for asking for a Client Script? You could achieve such a condition using zero code: UI Policy.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 08:47 AM
Hi Mark,
Actually I have tried this with UI policy but its not working on Service Portal form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 02:51 PM
Hi Prachi,
Would appreciate if what has been done is shared with us.
I'm a little bit confused by "today". Is the question about comparing a date field with today and hiding a field if the date is after today's date? If the question is about comparing the system assigned "Created" (sys_created_on) date, it would always be false because the "Created" will always be before or on today.
Example of UI Policy to compare a field of type date with today and hiding a field if the date is after today.
1. Created 2 variables as below. Field "Today" will contain a date and Field "Field to hide" will be hidden based on value of field "Today".
2. Defined UI Policy as follows:
3. Defined Policy action as follows:
Execution results:
Case 1: Date is today. Field "Field to hide" is displayed because the condition to hide is "after" today.
Case 2: Date is tomorrow. Field "Field to hide" is hidden.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 09:46 PM
Hi Hitoshi,
Thank you for your reply, my query is I don't want to show one field in future cases. The field should be visible on all past cases but it should be hidden from tomorrow in all future cases.
To achieve this I was writing UI policy on Created field but it is not working.