How to restrict a specific time card category from a user with wm_agent role

Rhonda9
Tera Expert

Hello,

 

I have a requirement to restrict the "overtime" time worked and time card category from users with the wm_agent role.    I created a client script but it is not working.   I think that is the way to go but scripting is a challenge for me.   What am I doing wrong?

 

function onLoad() {


//Type appropriate comment here, and begin script below

 


if (g_user.hasRole('wm_agent'))


g_form.removeOption('category', 'overtime');

else if (g_user.hasRole('wm_qualifier'))


return;


}

 

 

Rhonda9_0-1692715107990.png

 

1 ACCEPTED SOLUTION

Rhonda9
Tera Expert

Yes, the backend name is "category".  I added the alert and not seeing the alert come through.

View solution in original post

4 REPLIES 4

umaaggarwal
Giga Guru
Giga Guru

Hi looks ok, however could you please check what is the backend value of overtime ? is it the same what you have used or something else ?

 

Also try using alert which shows if it is even reaching your if block. 

alert(g_user.hasRole('wm_agent'));

Rhonda9
Tera Expert

Yes, the backend name is "category".  I added the alert and not seeing the alert come through.

Rhonda9
Tera Expert

I did get an alert box with "true".

Rhonda9
Tera Expert

I found the issue.  Thank you for your help.