Make New/Edit button on related list to be visible for certain role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 12:53 AM
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
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 01:37 AM
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 02:47 AM
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;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 02:55 AM
if(parent.approval == 'approved' && gs.hasRole('change_admin')) {
answer=false;
}
else
answer=true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2017 03:04 AM
var answer = true;
if(parent.approval == 'approved' && gs.hasRole('change_admin')) {
answer=false;
}
answer ;
try now