Remove the "Everyone" view permission for a news i

Posted by Community Admin on 04-Aug-2018 01:49

Remove the "Everyone" view permission for a news item

All Replies

Posted by Community Admin on 18-Nov-2016 00:00

I'm creating a news item through the api and in the same process assign view permission only to certain roles. 

I've managed to break the inheritance and assign the correct view permission but I'm unable to remove the permission for "Everyone" through the api...

It seems that if I use:

var everyonePermission = newsManager.GetPermission(SecurityConstants.Sets.General.SetName, newsItem.Id,
                    SecurityManager.ApplicationRoles[SecurityConstants.AppRoles.Everyone].Id);

It returns null. So if I then create the permission for everyone and ungrant access to view the item it throws and exception saying that it can't create a duplicate key in the sf_permissions index which means that this permission must already exist.

I've tried this at various points in the lifecycle of creating the news item, before and after publishing it, using the master item. All to no avail.

So my question is: how do you possibly remove the Everyone view permission?

This thread is closed