Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I like to be able to hide my list and the list should only be visible to the person who created it. I've created a custom action -> ribbon to perform that action. Right now when the ribbon button is clicked, the list will be set to hidden using Client Object Model like this :-

list.set_hidden('true');
list.update();

But how do I make this list visible only to the creator of this list, because once I've hide it, it will not be visible at all and the only way to show this list again is via SharePoint Designer.

Could you guys please help me?

share|improve this question
    
Is it an option to break inheritance of rights? I mean that you create new rights for this list to kick off everybody else? –  Shegit Brahm Feb 17 '12 at 14:02

2 Answers 2

In you scenario any user can access to this list, if this user know list url. I think that the best way is to use Unique Permissions for the list. You can set it like this:

public static void AssignPermissionsToItem(SPWeb web, SPSecurableObject secObj, SPPrincipal obj, SPRoleType roleType)
{
    if (!secObj.HasUniqueRoleAssignments)
    {
        secObj.BreakRoleInheritance(false, true);
    }

    SPRoleAssignment roleAssignment = new SPRoleAssignment(obj);
    SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(roleType);
    roleAssignment.RoleDefinitionBindings.Add(roleDefinition);

    secObj.RoleAssignments.Add(roleAssignment);
}

secObj - SPList, obj - SPUser

In this case the link to the list is displayed for users that have rights.

share|improve this answer
    
Thanks, but this is not gonna solve my problem. And my question was about using the client object model - javascript and not the server object model (I've already have the code for this). If you were to give me this in javascript I would have tick this as answered (because I was really struggling with it). Thanks anyway and I really appreciate your effort. –  Agamand The True Feb 20 '12 at 9:14
    
I think that you can not use js for this issue, because the user should has administarator rights to set permission to the list. But the common users does not have this rights. In this case you should elevate privileges for the user. But I don't thik that it is possible in JS :( –  Alexander Feb 20 '12 at 10:40
up vote 1 down vote accepted

Apparently what my requirements is not achievable with SharePoint permission (as far as I know, please correct me). The requirement is to hide the Looked up list. E.G. I created two custom list, one is named States and the other one is named Country. States is set to LookUp the Country list. My pm asked me to hide the Country list. I'm using the the Contribute permission set for most of the users because I want them to Add new State item. Even if I create my own permission set with these settings:- View Item, View Pages and Open (and then break inheritance on the List level and remove the Contribute permission level and set this permission to the Member group ), I still can see my Country list (I can't add new item to that list though). So my solution is to create an application page that will let the user with the Full Control permission to hide or unhide those lists.

Thanks for trying to help me, really appreciate it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.