Hide field based on state and role of user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 09:23 AM
Hi,
I have a requirement, if state is draft and user contain csd_admin, csd_user roles then i have to make Program field Visible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 09:37 AM
Please write a onload client script and mention the code as follows:
if(g_form.getValue("state")== 1 && g_user.hasRole("csd_admin") || g_user.hasRole("csd_user") ){ //check the backend
value of draft
g_form.setDisplay("program", "true"); // please check the backend name of program and mention here
}else{
g_form.setDisplay("program","false"); //here too..
}If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 09:43 AM - edited 05-05-2023 09:51 AM
You can use a UI Policy where State is Draft and then use the Script section (Execute if True section) of it to check for roles like the following:
function onCondition() {
if(g_user.hasRoleExactly('csd_admin') || g_user.hasRoleExactly('csd_user')) {
g_form.setVisible('<name_of_field>', true);
}
}
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 05:18 PM
this conditions are applying to the admin also. but i need to hide that fields only for the particular role users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2023 06:36 AM
Hi @VSN,
You can use a UI Policy where State is Draft and then use the Script section (Execute if True section) of it to check for roles like the following:
Execute if True section:
Execute if False section:
Please mark reply as Helpful/Correct/Accept Solution, if applicable. Thanks!
Thanks & Regards
Jyoti Jadhav
