Query on Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
26m ago
Hello Everyone,
I am facing an issue related to impersonation and field behavior in ServiceNow.
I wrote a Client Script where, if a specific user is impersonated, the Assignment Group field should become read-only; otherwise, it should remain editable.
The logic is working correctly for other fields, and even the setMandatory() functionality works as expected. However, setReadOnly() is not working specifically for the Assignment Group field.
I verified that:
The script is executing properly
The impersonated user is being identified correctly using g_user.userID
The same logic works on fields like short_description and category
But for assignment_group, the field still remains editable.
Could anyone please help me understand:
Is there any restriction specific to the assignment_group field?
Could a UI Policy, ACL, or dictionary configuration be overriding the Client Script behavior?
What would be the best approach to make assignment_group read-only during impersonation?
- here I have uploaded my code
Any guidance would be greatly appreciated.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20m ago
Hi @vodnalar26 ,
A field can be set readonly only if it is not mandatory.
If this field is mandatory then call g_form.setMandatory('assignment_group',false) before setting readonly.
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
41 seconds ago
if that field is mandatory then you can't make it readonly
As per approach shared by @palanikumar make it non-mandatory and then readonly
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
