How to apply UI Policy by logged in user (Admin override)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2011 08:13 AM
Is there a way to override a UI policy based on the current logged in user? I'd like to remove the mandatory requirement on a field for admins. I don't appear to be able to modify the conditions field to insert a test of userObject. In the list view the field is locked down ("This element type is not editable from the list."); adding a list-edit ACL on sys_ui_policy.condition has no effect.
Thanks,
Brian Rowland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2011 08:50 AM
That's one of the current limitations of UI Policy. Their condition is solely based on the data, not the user. Nor is there a scriptable condition capability. I'd definitely like to see the first addressed, which would largely remove the need for the 2nd.
Closest you could come would be to make the field mandatory or not with the two script blocks, after checking the "Run scripts" checkbox, and using g_form.setMandatory("your_field", true); just like you'd do with a client script. This line would be after an IF statement checking the user role: if (!g_user.hasRole("admin"))
Or you could just use a client script, unless you like having everything in UI Policies where possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2011 10:15 AM
Thanks CapaJC,
Keeping the UI Policies in the UI Policies makes the most sense to me as far as keeping similar behaviors organized, so I'll try overriding the field policies in the script blocks.