Friday, February 28, 2014

Custom Permissions on SharePoint List/Library View

SharePoint any version does not offer permissions at a view level. You can have item level permissions, but not view level permissions. There is no easy way or server side method available.

I had a situation where it would be nice if  I could permissions at the view level. Over a year ago, I had a similar problem, but that time I told the client there was no way to set permissions at the view.

Here is a solution to set permissions at a view level. I will take a pages library in my example. In this example, if the current user does not belong to site owners group, they would be redirected to home page.

Assumptions

  • Pages Library provisioned
Solution
  1. Create a new .JS file and add it to anywhere on the site (Hint: SiteAssets)
  2. Add code like this below
  3. Goto AllItems.aspx page/view and click edit.
  4. Add a CE to the page.
  5. Link the CE to this .JS file. (That is all required)
Note: Make sure you are using the right version of SPService and Jquery as they seem to have compatibility issues.


<script src="http://code.jquery.com/jquery-1.11.0.js" type="text/javascript"></script>
<script src="/SiteAssets/jquery.SPServices-0.7.1a.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
//Do this for All Documents Views. The regular user does not need to view "All Documents" view.
  $().SPServices({
           operation: "GetGroupCollectionFromUser",
           userLoginName: $().SPServices.SPGetCurrentUser(),
           async: false,
           completefunc: function (xData, Status) {
               if ($(xData.responseXML).find("Group[Name='Site Owners']").length != 1) {
location.href = location.href.replace('/Forms/AllItems.aspx', '/Default.aspx');
               }
             
           }
       });
        


});


Thursday, February 27, 2014

Issue - Unable to install farm solution via Central Admin

Error: Access denied.  Only machine administrators are allowed to create administration service job definitions of type: Microsoft.SharePoint.Administration.SPSolutionDeploymentJobDefinition, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c.

Solution for Windows Server 2012

Click Here to Solve this issue


Ratings Control SharePoint 2013 On-Prem

Adding ratings control in SharePoint 2013 on-premise requires going via Design Manager.

Here is the process:

  • Publishing Feature should be turned active.
  • Pages library should be provisioned
  • Go to Library Settings as in the image and make changes.
  • Once Ratings have been turned on, open your custom master page/page layout via Design manager to add this code.
  • Add this code inside the Head section
<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->
<!--SPM:<%@ Register TagPrefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls"  Assembly="Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>-->
  • Add this code where you want to display the average ratings
 <--<div class="article-content" align="left" style="left:0px; width:100px">
            <!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->
<!--SPM:<SharePointPortalControls:AverageRatingFieldControl 
   ID="PageRatingControl" 
   FieldName="AverageRating" 
   runat="server"/>-->
<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->
           </div>-->