Posted on Leave a comment

Missing “Save Site As Template” Option in SharePoint Online, Office 365 and SharePoint Server 2013

The ability to save site as a template may be missing in SharePoint at times. This article explains why it might be missing and what your options are.

The most common reason that people notice the “Save site as template” option missing in SharePoint has to do with the enabling of SharePoint publishing feature. When you enable the SharePoint Server Publishing feature, it disables the ability to save the site as a template.

 

The Consequences of Deactivating Publishing

While it’s possible to save a publishing site as a template if you temporarily deactivate the publishing feature, it will be a huge mistake. I don’t recommend you use this workaround under any circumstances. This could be a recipe for disaster because although saving the site as a template would work fine, in the future when you try to use a template that was created by deactivating the publishing feature, you are likely to have all kinds of problems. Among other issues, you may see the following error message:

Provisioning did not succeed. Details: Failed to initialize some site properties for Web at Url: ‘……’ OriginalException: Failed to compare two elements in the array.

For all practical reasons, a template that was created by turning the publishing feature off, should be considered “infected with bugs” that are going to bug you (no pun intended) down the road. Technically they are not bugs at all, it’s just that the publishing feature contains certain site elements that a site template doesn’t support. In other words, once you enable publishing on a SharePoint site, there are components that can’t be turned off, even if you disable publishing. That’s why it’s so important that you plan your SharePoint deployment BEFORE you deploy SharePoint on your network.

WARNING! Avoid deactivating the publishing feature just so you can save the site as a template.

If you accidentally enabled publishing or community feature on a SharePoint site, you are better off saving your site content, deleting the site, and creating a new site with the appropriate template. Keep in mind, that when you delete a site, all content will be lost. You won’t be able to go to the Recycle Bin and recover your data.

Posted on Leave a comment

SharePoint: Filter on Current User’s Group Membership

You are likely already aware that you can apply a filter condition to a CAML query to return only items where a specified user or group field is equal to the current user. What is less obvious is that you can also apply a filter to return items where the field contains a group of which the current user is a member.

SharePoint: Filter on Current User’s Group Membership

You are likely already aware that you can apply a filter condition to a CAML query to return only items where a specified user or group field is equal to the current user.

In SharePoint’s view settings UI, you would do this by filtering where the field is equal to “[Me]”. The corresponding CAML query snippet (assuming “AssignedTo” as the internal name of the field) would be:

<Eq>
     <FieldRef Name="AssignedTo" />
     <Value Type="Integer">
          <UserID/>
     </Value>
</Eq>

What is less obvious is that you can also apply a filter to return items where the field contains a group of which the current user is a member. In fact, one of the built-in list templates comes with a view that already has such a filter: the “By My Groups” view on the task list.

If you don’t have access to compose your own CAML query, you can achieve the “By My Groups” view by creating a content type that inherits from the Task content type (assuming you do not delete the “AssignedTo” field).

The corresponding CAML query snippet for filtering on the current user’s groups is this:

<Membership Type="CurrentUserGroups">
     <FieldRef Name="AssignedTo" />
</Membership>

To take it a step further, you can compose your own composite CAML query to filter on items assigned to the current user directly OR assigned to a group in which the current user is a member:

<Or>
     <Membership Type="CurrentUserGroups">
         <FieldRef Name="AssignedTo" />
     </Membership>
     <Eq>
          <FieldRef Name="AssignedTo" />
          <Value Type="Integer">
               <UserID/>
          </Value>
     </Eq>
</Or>