Make New/Edit button on related list to be visible for certain role

jenny32
Tera Guru

Hello Everyone,

I am trying to make New/Edit button on related list of Change Request form to be visible for change_admin role. I have written script in list control to make those buttons not to be visible when the Approval of Change is Approved and i want to make these buttons visible to change_admin even when that condition is met. I used gs.hasRole('<role_name>') in the 'Omit Edit/New condition' field, but it didn't work.

Can anyone suggest me how i can achieve this, please?

Thanks In advance!!

Regards,

Jenny

9 REPLIES 9

Sagar Patro
Kilo Guru

Hi Jennifer,



I did face similar issue sometime back but soon realized that it was a silly mistake. I reviewed my implementation and docs article.


find_real_file.png


Reference: Advanced list control with scripts


Please verify if above fixes the issue. If not please review the CREATE ACLs for the table you are trying to hide the new button of.


Hello Vidyasagar,



I got it worked for the condition when Approval of change is Approved, i am disabling the New/Edit buttons and i want to add one more condition to my code saying even when the Approval of change is Approved, those buttons should be visible only for users with 'change_admin' role.


I tried using gs.hasRole('change_admin') in my code but it didn't work.



Here is my code to disable the buttons for all users irrespective of roles:


var answer;


if(parent.approval == 'approved'){


answer=true;


}


else{


  answer=false;


}



Initiailly i used the below code and i didnt get the expected result.


if(parent.approval == 'approved'){


        if(gs.hasRole('change_admin'){


                  answer=false;


        }


        else


                    answer=true;


}


else{


  answer=false;


}


if(parent.approval == 'approved' && gs.hasRole('change_admin')) {


                  answer=false;


        }


        else


                    answer=true;


}


var answer = true;



if(parent.approval == 'approved' && gs.hasRole('change_admin')) {


                  answer=false;


        }


answer ;



try now