Unable to set caller field readonly with setReadOnly()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
looks like you are trying to set default value in caller_id with logged in user
Why not use default value in dictionary as this -> gs.getUserID()
OR
Why not use display business rule on incident table and set it like this?
current.setValue('caller_id', gs.getUserID());
💡 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Can you try with this execution order once:
g_form.setValue('caller_id', g_user.userID);
g_form.setMandatory('caller_id', false);
g_form.setReadOnly('caller_id', true);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello @SanjivaniLahane ,
plz check for the other ui policies on caller _id field if there is any..
that can override your script.
also try using this fix :
function onLoad() {
g_form.setValue("caller_id", g_user.userID);
g_form.setMandatory("caller_id", false);
g_form.setReadOnly("caller_id", true);
}
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 hours ago
Hi @SanjivaniLahane , First of all, check if there are any UI policies applied to the field with the same logic/condition cause if this is true then the UI policies will take precedence and client script will be overridden by UI policy.
The code that you have written is perfectly fine.
And if not this could you clarify the requirement more, like what are you trying to do exactly?
If this response helps you mark it as accepted solution and give it a thumbs up 👍. This help me and community to find answers quickly.
Best Regards,
Saurabh V.