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 find_real_file.png

Even when I impersonate a user that is selected as the Domain Steward or Architecture lead(owner) for the current record, the edit button doesn't appear. My code is:

answer = checkCondition();

function checkCondition(){

    var title = gs.getUser().getRecord().getValue('title');

    if(title == 'Domain steward' || title == 'Architecture lead (Owner)' || gs.getUser().isMemberOf('Architecture Domain Admin'))
        return false; // show it
    else
        return true; // omit it
}

 

I also have 'Omit is empty' selected.

Hi,

what does this mean?

user that is selected as the Domain Steward or Architecture lead(owner) for the current record

I have assumed that is user's title. Is it correct understanding?

OR is there any field on your current form which holds that information?

Regards
Ankur

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

Hi @Ankur Bawiskar  yes so the edit field has to appear if the user is selected as the Domain Steward or Architecture lead(owner) for the current record or is a member of the 'Architecture Domain Admin' group.

 

The 'title' appears on the sys_user table, which is different.

 

Can you dot walk on fields on the form?

Hi,

Are these 2 fields on form "Domain Steward" and "Architecture lead(owner)"?

if yes then update as this

Ensure you give correct field name from Knowledge table which holds Architecture record

Also give correct field name for Domain Steward and Architecture lead(owner)

answer = checkCondition();

function checkCondition(){

	var leadUser = parent.u_architecture.u_architecture_lead;
	var domainUser = parent.u_architecture.u_domain_steward;
	var loggedInUser = gs.getUserID();

	if(leadUser == loggedInUser || domainUser == loggedInUser || gs.getUser().isMemberOf('Architecture Domain Admin'))
		return false; // show it
	else
		return true; // omit it
}

Regards
Ankur

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

@matthew.hughes@lloydsbanking 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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