How to make dot walked field read only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
50m ago
I have dot walked X field from Y table. Written UI policy to make that read only , still editable on new forms(has to be read only). Tried with OnLoad Client Script. Still no luck. Please assist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
43m ago - last edited 41m ago
Hi there,
This is a classic challenge.
The reason your UI Policy and Client Script are failing is that dot-walked fields are often not fully available in the DOM context during the initial 'New Record' rendering, or they bypass client-side logic because they reference the parent table directly.
As a best practice, I recommend moving this logic to the Server Side using a Data Policy.
Here is why this works better:
-
Server-Side Enforcement: It enforces the 'Read Only' state at the server level, meaning it works for New Records, List Edits, and even API imports.
-
UI Policy Integration: If you check the 'Use as UI Policy on client' box in the Data Policy, it will still behave like a UI Policy visually, making the field read-only as soon as the form loads.
How to do it:
-
Navigate to Data Policies > New.
-
Select your Table X.
-
Set your conditions (if any).
-
In the Data Policy Rules related list, add your dot-walked field from Table Y and set Read Only to True.
This is much more reliable than fighting with Client Scripts for cross-table fields. Let me know if this solves it for you!
OR.....
Alternatively, if you strictly need to keep your logic within Client Scripts, there is a common workaround:
-
Add the field natively: Instead of just dot-walking, ensure the field is physically present on the form layout.
-
Hide it via UI Policy: Create a UI Policy to keep this field hidden (Visible = False).
-
Reference in Script: Once the field is part of the form DOM (even if hidden), your Client Scripts and UI Policies will be able to target it and enforce the 'Read Only' state more reliably.
However, keep in mind that the Data Policy approach mentioned above is usually cleaner as it requires zero scripting and handles 'New Records' natively without DOM dependency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
41m ago
Hi @KS86 ,
Yes, dot-walked fields are generally displayed as derived/reference fields and often appear read-only on the form. However, the key point is that a dot-walked field is not a real field on the current table. It is a field from the referenced record.
Example:
Current table: incident
Reference field: caller_id
Dot-walked field: caller_id.company
caller_id.company is actually the Company field on the User record, not a field on Incident.
So if your goal is to make that value read-only, you should not only control it from the current table’s UI Policy. You need to control the actual source field or the reference behavior.
If the reference field itself is made read-only, the dot-walked fields under it are usually read-only as well. For example, if caller_id is read-only, then caller_id.company will normally be read-only too.
If you want the user to still change the reference field but not edit the dot-walked value, the better options are:
1. Make the actual source field read-only using dictionary or write ACL.
Example:
For caller_id.company, secure the Company field on the sys_user table.
2. Use a local read-only display field instead of a dot-walked editable field.
Example:
Create u_caller_company on Incident, populate it from caller_id.company, and make u_caller_company read-only.
3. If this is only for form display, try a client script:
function onLoad() {
g_form.setReadOnly('caller_id.company', true);
}
But the client script is only UI-level control. It is not security.
Dot-walked fields often appear read-only by default, but do not rely on that as a security control. If the field must be protected, secure the actual source field with ACL/dictionary rules, or use a local read-only display field on the current table.
Thank you,
Vikram Karety,
ServiceNow Architect,
Octigo Solutions INC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
40m ago
this onLoad client script worked and made dot walked field readonly on new and existing record
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
