Anyone had luck with hasRoleExactly?

bradfournier
Kilo Expert

I have a Form button UI Action that I'm trying to narrow a condition for. I currently have it written as:

g_user.hasRoleExactly('help_desk') && (current.state != '6' && current.state != '7' && current.state != '8')

This is not working. I have broken it up and tested each condition individually, all of the state checks work fine but the role check will not even work on its own. I have also tested using the basic hasRole() and that works fine, but due to admin privileges need to use hasRoleExactly. Does anyone have any experience using this function that might be able to give me some insight as to why this isn't working?

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

I stand corrected. As I mentioned earlier you can only use server side code in the conditions. Try my code as mentioned in my previous response



(gs.getSession().getRoles().indexOf('help_desk') >-1) && (current.state != '6' && current.state != '7' && current.state != '8')


View solution in original post

15 REPLIES 15

veena_kvkk88
Mega Guru

Hi Bradley,



hasRole() returns true if the user has the specified role or an admin role. You don't want admins to get access either?


Abhinay Erra
Giga Sage

You are mixing both client side and server side here. You can use this


(gs.getSession().getRoles().indexOf('help_desk') >-1) && (current.state != '6' && current.state != '7' && current.state != '8')


you can also use this :


g_user.hasRoleExactly('help_desk') && (g_form.getValue('state') != 6 && g_form.getValue('state') != 7 && g_form.getValue('state') != 😎



Thanks


Akhil


Hit Like/Helpful/Correct, if applicable.


FYI: I just went through the documentation. it does support both client side and server side scripts in conditions. This condition


g_user.hasRoleExactly('help_desk') && (current.state != '6' && current.state != '7' && current.state != '8') should work