Unable to hide or make the ‘When’ and ‘To’ read-only for specific event types in Calendar Events
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi,
We have a requirement to hide or make read only the When & To in Calendar events while creating new event from Team Calendar for only specific type.
When we analyzed we see this been created as formatter and not created as field in any table, has anybody faced similar issue?
Please see screenshot for details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi @Srinivasan7
The “When” and “To” fields you see on the Team Calendar event creation form are not real fields stored in the underlying table.
Instead, they are rendered by the calendar formatter (widget-like UI component).
Because they aren’t standard dictionary fields, you can’t just use Dictionary Overrides, UI Policies, or ACLs to make them read-only/hidden.
An option is write an onLoad Catalog Client Script (or UI Script depending on where you’re running it).
Use DOM manipulation (g_form.getElement() or document.querySelector) to hide or disable the date/time inputs rendered by the formatter.
See an example of code
function onLoad() {
var type = g_form.getValue('event_type');
if (type == 'restricted') {
var whenField = document.querySelector('[data-field="when"]');
var toField = document.querySelector('[data-field="to"]');
if (whenField) whenField.setAttribute("readonly", true);
if (toField) toField.setAttribute("readonly", true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you will have to use DOM manipulation via onload client script on the event form.
Remember this script should work only when the New event opens in modal
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Srinivasan7,
In ServiceNow, the When and To in Team Calendar are part of a formatter, not real fields, so UI Policies won’t work.
Solution:
Use an onLoad Client Script → check event type and hide/disable those fields with DOM manipulation.
Add a Business Rule (optional) to block updates on server side for security.
This way, users can’t edit When and To for that specific event type.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.