How to make the edit button on a related list appear for certain users

matthew_hughes
Kilo Sage

On the below form, the 'Edit' button appears within the 'Knowledge' related list:

find_real_file.png

 

However, I only want to make the 'Edit' button available for the current record if the user is either the 'Architecture lead(owner)', 'Domain Steward' or a member of a particular group. 

What would I need to add to the List Control?

1 ACCEPTED SOLUTION

matthew_hughes
Kilo Sage

I've managed to do this by using 'List Control' and applying a script that checks if the current users has the required role and then if they are set in the one of the fields on the form.

View solution in original post

15 REPLIES 15

Hi @Ankur Bawiskar 

 

I tried the following code:

function checkRole() {
    if (gs.hasRole('lbg_architecture_domain_admin')) {
        return false; // show it
    } 
    else if(gs.hasRole('lbg_architecture_domain_manager')) {
        if (parent.u_architecture_domain.owned_by == gs.getUserID() || (parent.u_architecture_domain.managed_by == gs.getUserID())) {
            return false; // show it
            }
    }
        
    else {
        return true; // omit it
    }
}
checkRole();

 

However, I think it might be related to the create ACL because the Edit button will appear if I specify a role within the Crete ACL.

Hi,

edit button also checks if the logged in user satisfies the field level WRITE ACL

i.e. field present on related list table u_architecture_domain is being allowed write Access or not

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

User should have the "write" access on the related list table to see this "Edit" button because even though i wrote the above script in "Omit Edit condition", users still don't see the "edit" button on the related list.

If they need "write" access on the table but we don't want to give to them this access, is there still any option we can still grant the "edit" button access?

Any help much appreciated.

Swapnil Shirsik
Giga Guru

Hi Matthew,
I presume there would be limited users who are Domain Steward or Architecture lead(owner), so is it possible to add them to the existing 'Architecture Admin Group' or create a new group and then use this group as a condition in Omit edit condition script?

Example script-

function checkDisplay()
{
if (gs.getuser.isMemberOf(('Architecture Doman Group' || ('New_group_if_you_create'))
{
return false; // this should display Edit button
}
else
return true; //this should not display Edit button.
}

 

Please mark this answer as helpful/correct based on the impact.

matthew_hughes
Kilo Sage

I've managed to do this by using 'List Control' and applying a script that checks if the current users has the required role and then if they are set in the one of the fields on the form.