Hide/show buttons with list control

Leonel Sandroni
Tera Guru

Hi there,

I'm trying to hide or show buttons and links from related list so I have tried with scripts in 'omit conditions'.

The requirement is very simple. Users, who have ACL write permissions for parent record, should be able to create or edit related list records. 

I have achieved  to hide links for users that have no permissons but it's not working with the 'New' button

LeonelSandroni_0-1689693696211.png

This is the script which I have write for both conditions:

var omit = true;


if (current.parent.canWrite()) {


  omit = false;


}



answer = omit;

 

and as I mentioned it works for 'omit links' but not for 'omit new'

Any suggestion?

9 REPLIES 9

I have found the solution. You just need to be sure that ACLs in parent table are propertly configured and it's very important. The script is working without problems. In fact, you can use a more simplify script like this:

if (parent.canWrite());
true;
else;
false;




Sagar Pagar
Tera Patron

Hi @Leonel Sandroni,

 

You need to check with parent.canWrite() method. Try this updated scripts,

var answer;
if (parent.canWrite() == true) {
	//Do not remove the 'New' button
	answer = false;
} else {
	//Remove the 'New' button
	answer = true;
}
answer;

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.

Thanks,
Sagar Pagar

The world works with ServiceNow

This script hides the new button for all users but I'll try tro modify it.  Thanks

Hi @Leonel Sandroni,

 

For me it is working as expected!

If user do not have write access for demand. The New button will be hidden.

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Ok, I should check the ACLs in dmn_demand_task. Maybe I have modified OOTB 'create' ACL.