UIPolicy - for loggedin user is member of group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-13-2022 11:25 PM
Hi I have 3 fields in problem table, if logged in user is member of Few groups then I need to remove mandatory for impacted business service field and readonly false to lob and impacted customer fields if not vise versa. for this I have written a UI policy script with assignment group but when I'm trying to edit the list type field I was not able select any value and unlock the list type field
function onCondition() {
var isMember = gs.getUser().isMemberOf('sys_id');
if(isMember == true){
g_form.setReadOnly('u_lob',false);
g_form.setReadOnly('u_impacted_customer_s',false);
g_form.setMandatory('u_impacted_ci_s',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-13-2022 11:35 PM
gs.getUser().isMemberOf('sys_id'); is server side code you cannot use that in UI policy.
Instead follow below:
1. Create a display BR on your table with below code:
g_scratchpad.mem = gs.getUser().isMemberOf('sys_id');
2. Now create a client script (on change/ onload) as per your req and then use below code:
if(g_scratchpad.mem) // code will run if user is member of group defined in. display BR.
{
g_form.setReadOnly('u_lob',false);
g_form.setReadOnly('u_impacted_customer_s',false);
g_form.setMandatory('u_impacted_ci_s',false);
}
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023