List Control

sunny13
Giga Expert

Hi All,

I'm trying to hide "Edit" in the change task related list by using advance script in list control   for people without change_manager role and also there is an OR condition with respect to state.

Please review my code,

var answer;

if(gs.hasRole == "change_manager" ) ||   (parent.state=='3' || parent.state=='4' || parent.state=='-2' || parent.state=='-13' || parent.state=='-14' || parent.state=='2' || !parent.active;)

{

  answer=false;

}

else{

  answer=true;

}

But what happens is the EDIT button is not visible to anyone with any role except ADMIN i even revoked all changes but the EDIT button is missing from the related list.

But NEW button is visible to Users

find_real_file.png

Can someone help me debug this issue.

1 ACCEPTED SOLUTION

The change_task table should be editable to the user. Make sure the MPI


Change Manager has write access to the table.


View solution in original post

31 REPLIES 31

When you reverted, did your Edit button appear before you started attempting to use ACLs? I thought you were still having issues.



(from the original message)


i even revoked all changes but the EDIT button is missing from the related list



I may have missed an update where you got it working again.


The issue seems to be there for quite sometime .



Even before i made changes to List control i have not seen EDIT button for non admin users and also i confirmed with users that the EDIT button is missing for them for long time.



Only NEW button is visible to NON ADMIN users and where ADMIN has new and edit button.


Now i'm trying to find why EDIT button is missing for NON ADMIN users though i have not put any condition or required roles in the list control.



find_real_file.png



find_real_file.png


Hello Sajin,



Now, your issue is more clear than before.



1.   The 'Edit...'   UI Action in the related list is meant to update the change task record. Now, we cannot use an ACL to restrict write rule for change_task table, as we do not know which change Task is going to be linked with the change record. So, ACL is out of the picture.



2. The best way to restrict this is by adding an 'omit edit condition' to the List Control.



Refer Configuring Lists - ServiceNow Wiki   to see examples. or look at other List Controls for working examples.


You Edit condition should be something like this:




People without change manager role: !gs.hasRole('change_manager')



Conditions related to state: parent.state == '4' || parent.state == '2'   ... etc



final condition should look like this:




find_real_file.png



Code:


var answer;




if(gs.hasRole("change_manager") ||   parent.state=='3' || parent.state=='4' || parent.state=='-2' || parent.state=='-13' || parent.state=='-14' || parent.state=='2' || !parent.active){


  answer = false;


} else {


  answer = true;


}


answer;


Thanks for the detailed info .



What ever condition you have mentioned is true but for some reason when i impersonate as a user with MPI change Manager role i don't find the EDIT button on the related list.



if(gs.hasRole("MPl Change Manager") ||   parent.state=='3' || parent.state=='4' || parent.state=='-2' || parent.state=='-13' || parent.state=='-14' || parent.state=='2' || !parent.active){


  answer = false;


} else {


  answer = true;


}