Query on Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
3 weeks 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @vodnalar26
A field cannot be both mandatory and read-only at the same time.
As a workaround, you can initially keep the field mandatory. Once the user enters a value, create a UI Policy that checks whether the field is not empty, and then use a UI Policy Action to make the field read-only.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti