Add condition to UI Policy to check if user who is logged in has role 'admin'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 12:04 AM
Hi All!
I have a Catalog UI Policy which make one field in INC form read only.
I want to add condition to check if currently logged in user has role 'admin' to exclude this users to make them able to change this field if it will be needed.
So condition will sth like: if user has not role admin then make field read only.
How can I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 01:34 AM
Hello @Kasia5 ,
I assume you might be using table level UI policy and not the catalog UI policy, and Yes you can simply achieve this by using the script below in advance run script section.
function onCondition() {
if (!g_user.hasRole('admin')) {
g_form.setReadonly('fieldname', true); // Set field readonly
}
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 11:32 AM
Hello @Kasia5
I wanted to check in regarding the response I provided. If my suggestions were beneficial in addressing your query or helped in resolving your issue, would you mind marking it as helpful, accepting the solution, and closing the thread? Your acknowledgment not only shows appreciation for the assistance but also assists future readers who might come across a similar problem.
Thank you for your consideration!
Best regards,
Aniket.