Why is the cmdb_ci field still editable when it should not be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I am trying to troubleshoot why the cmdb_ci field is still editable after I apply "Run If False" code in a UI Policy.
Here is my Run if True code:
function onCondition() {
if (g_user.hasRole('usb_unauth_change_manager') || g_user.hasRole('change_manager')) {
g_form.setReadOnly('cmdb_ci', false);
g_form.setReadOnly('short_description', false);
//alert("Andrew Wuz Here 1");
} else {
g_form.setReadOnly('cmdb_ci', true);
g_form.setReadOnly('short_description', true);
//alert("Andrew Wuz Here 2");
}
}Here is my run if false code:
function onCondition() {
if (g_user.hasRole('usb_unauth_change_manager') || g_user.hasRole('change_manager')) {
g_form.setReadOnly('cmdb_ci', true);
g_form.setReadOnly('short_description', true);
alert("Andrew Wuz Here 3");
} else {
g_form.setReadOnly('cmdb_ci', false);
g_form.setReadOnly('short_description', false);
//alert("Andrew Wuz Here 4");
}
}
The alert dialog for "Andrew Wuz Here 3" appears fine. What is overriding my readonly lines?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
54m ago - last edited 52m ago
I'll infer from the last word of your post, not specified earlier, that short description is also editable? When this script runs are either or both fields populated? Is either field mandatory? It would also be extremely helpful to know on which form/table is this UI Policy. What is the condition for this policy? When all 4 alerts are uncommented, do you only receive the correct one in each test case? You likely have a different UI Policy, Data Policy, or Client Script on the same table affecting these fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
24m ago
may be some other UI policy of higher order?
did you debug that?
💡 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
