I have a list of projects with three different status based on the user permission. What I want is that some list items will show to the user based on their permission and the rest will be hidden. Is this possible?

Possible to use a web part content query to extract items from a list based on their permission? Or any other way?

  • This is default behavior. If you use item level permission only items that users has access to will be shown (regardless in is it list view web part of content query). Are you hitting any issues with your solution? Oct 9, 2018 at 7:59

2 Answers 2


You can use JavaScript code as below:

function breakInheritance() {
    var clientContext = new SP.ClientContext.get_current();

    var oList = clientContext.get_web().get_lists().getByTitle('TestList');

    this.item = oList.getItemById(2);

    // Break inheritance. If argument is 'true' then parent list
    // permissions are kept as is. If 'false' then parent list 
    // permission are removed.

    this.oUser = clientContext.get_web().ensureUser('DOMAIN\\user');
    var collRoleDefinitionBinding = SP.RoleDefinitionBindingCollection.newObject(clientContext);
    this.roleDefs = clientContext.get_web().get_roleDefinitions();

    //Assign 'Reader' permission level to user

    //Assign '<CUSTOM PERMISSION LEVEL>' permission level to user
    collRoleDefinitionBinding.add(roleDefs.getByName("<CUSTOM PERMISSION LEVEL>"));

    item.get_roleAssignments().add(oUser, collRoleDefinitionBinding);


    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args) {


function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Reference MSDN Article

  • @Arte2 Please don't forget to upvote and mark the answer as accepted in case it helped you!' Oct 9, 2018 at 18:15

For classic view, you could hide list item by CSR.

Below is sample script to hide list item if user have not edit permission for list item.

<script type="text/javascript">
    (function () {
        function OnPostRenderTemplate(ctx) {
            SP.SOD.executeOrDelayUntilScriptLoaded(loadContext, 'sp.js');
            function loadContext() {
                var rows = ctx.ListData.Row;
                var call = jQuery.ajax({
                    url: _spPageContextInfo.webAbsoluteUrl +
                    type: "GET",
                    dataType: "json",
                    async: false,
                    headers: {
                        Accept: "application/json;odata=verbose"
                var manageLists;
                call.done(function (data, textStatus, jqXHR) {
                    var manageListsPerms = new SP.BasePermissions();
                    manageLists = manageListsPerms.has(SP.PermissionKind.manageLists);
                for (var i = 0; i < rows.length; i++) {
                    var row = document.getElementById(GenerateIIDForListItem(ctx, rows[i]));
                    if (manageLists) {
                        row.style.display = 'block';
                    } else {
                        row.style.display = 'none';


        function RegisterListViewTemplate() {
            var viewContext = {};
            viewContext.Templates = {};
            viewContext.Templates.OnPostRender = OnPostRenderTemplate;
        ExecuteOrDelayUntilScriptLoaded(RegisterListViewTemplate, 'clienttemplates.js');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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