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
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
3 weeks ago
Ok, I just checked it. The script was initially working with the setMandatory() method. Later, I changed the script method from setMandatory() to setReadOnly(), and after that, the issue started occurring specifically for the Assignment Group field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
please share your script and script config screenshots
Also share the outcome what you are getting
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
Hi,
Your script should be like below (both statement should be present):
g_form.setMandatory('assignment_group',false);
g_form.setReadOnly('assignment_group',true);
Palani