0

I have a site collection in share point online. Its has some lists and sub sites. Again the sub sites having some lists. Some sub sites and lists having unique permissions and some have inheritance permissions . I need to check whether the current login having permission level Approve for any lists in all the sub sites and lists using rest api. Actually i am looking for a function(sample code) which iterate the sites collection lists and sub sites lists for checking the Approve permission level for the lists. i am using /_api/site/rootWeb/webinfos to get the sub sites ServerRelativeUrl .

Can anyone help me please. Thanks in Advance

0

I don't have a ready made sample for your but here is a good starting sample to iterate all subsite: Most efficient way to get all sub sites under a site collection/sub site using JSOM?

Try extending the script at after "var web = webs.getItemAtIndex(i);" to query the site for it's lists and include in the load whether the list HasUniquePermissions en the Roleassignments.

0

Please check below sample code for get permission of current user in particular list.

function checkPermissions() {
    var call = jQuery.ajax({
        url: _spPageContextInfo.webAbsoluteUrl +
            "/_api/Web/Lists/GetByTitle('Test')/effectiveBasePermissions",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });

call.done(function (data, textStatus, jqXHR) {
    var manageListsPerms = new SP.BasePermissions();
    manageListsPerms.initPropertiesFromJson(data.d.EffectiveBasePermissions);

    var manageLists = manageListsPerms.has(SP.PermissionKind.ApproveItems);

    var message = jQuery("#message");
    message.text("Approve ListItem: " + manageLists);
});

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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