I would like to check in the item displaytemplate if the current user has contribute permissions on the current item. The current item is an site object because in my search query I use contentclass:"STS_Site". How to do that?

My target is to show the results where the current user has contribute permissions, in an other way. like a red border or something. Is this also possible with promoted results?

  • How do you want to check? using javascript? Commented Sep 30, 2015 at 8:20
  • What action you want to perform if a user has contribute permissions on an item?
    – Asad Refai
    Commented Sep 30, 2015 at 9:03
  • I would like to show the item in an other way. Add some extra css styling like a red border or something.
    – Ola
    Commented Sep 30, 2015 at 10:53

2 Answers 2


Check it using javascript. Make a GET request to the following URL


Above URL will return you current user's details along with user groups. From user's groups, you can check easily user has contribute permission or not.


You can try the below code in your Item Display template.I would highly recommend to think of an alternative , because every item will make a call to SharePoint, so it would take few more seconds to check the permission.

   function CheckPermission(url) {
        var isContributor = false;
        var clientContext = new SP.ClientContext(url);
        var currentSite = clientContext.get_web();
            var basePerm = new SP.BasePermissions();
            isContributor = web.doesUserHavePermissions(basePerm);
                //user has contribute permission
                //user does not have contribute permission
        }, function (sender, args) {
  • If got an exception "Object doesn't support this action" on this row: var clientContext = new SP.ClientContext(url);. Do you now why? I add this javascript inside the item displaytemplate
    – Ola
    Commented Sep 30, 2015 at 9:42
  • Make sure you pass the correct url to the method. Also SP.js is loaded before the call to this method
    – Unnie
    Commented Sep 30, 2015 at 9:44

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.