Columns with benefits

This question recently popped up in our Yammer network:

I’m trying to get my head around how tagging and search works in SharePoint.

Within a Document Library, I added a column and used it to add some keywords to each item. I then searched for the keywords but no results were returned. Does search only work with file names? Is the point of tagging like this only for filtering within the library and enabling various views?

I’m kind of confused at the moment. Obviously, what I want to achieve is to give a document a set of tags which would define that document and then use search to find that document based on the tags that it has been given. But if search only works with file names, maybe this approach will not work…

I thought it would be helpful if I published my response:

When you create a new list or library the only column visible to a search will be the “Title” column. (if you use other out of the box apps like an Issue tracker then there might be couple more). As you observe, filters and views will work as they are not reliant on search. Filters and views in SharePoint work like Sort and Filter in Excel as they allow you to slice the list or library through manipulation.

The contents of the Title column are available to search as the column has associated managed properties which are visible to search. I’d add a caveat that you might need to wait 15 minutes for search to become aware of new items added to columns with managed properties (more about that later). So it goes that if you want search to see content in other columns you need managed properties.

Creating managed properties is a dark art, and something administrators don’t enjoy doing (well this one at least!). It’s fiddly and easy to make mistakes. However, Microsoft know it is hard so they have created a safe path that Administrators and Site Owners can tread.

The safe path is to create “Site columns”. These are different to the columns you create when you add a column to a list, say through Quick Edit, as through that route SharePoint will only add a simple column. The scope of a simple column is limited to the list or library to which it is added. The scope of a site column is that of the site collection it was created in (and it can be wider than that). Site columns are used to establish a consistent, reusable definition across lists and libraries but their abilities go further than that.

Site columns are ‘columns with benefits’

Site columns are created via Cog > Site settings > Site columns (its normally the first option under the “Web Galleries heading”).

Now before you do this, there are some rules that I’d like you to follow (for the detailed guide how to create one check out an earlier post of mine “Reusable columns“). Please create your site column with a lower case camel name e.g. prjman rather than Project Manager as spaces and punctuation in internal names introduce unfriendly complexity. For example, if you create a site column with the name DC Project technology the internal would be DC%5Fx0020%5FProject%5Fx0020%5Ftechnology ! You can give it a friendly name once you have created it. If people are syncing content using OneDrive then you can only have a handful site columns per library. (And if your column uses managed metadata then that greatly reduces the number you can sync owing to lookup thresholds). Once you have defined your columns you can add them to your list or library, not via quick edit but only through the list or library settings.

At this point search is still unaware of the new column, you’ve merely created and added a reusable definition. The magic happens once you add some content to the column. So… Create a new item and populate the site column field, save it and grab a cup of tea (or a good night’s sleep) and come back to it later as the magic happens behind the scenes

Every 15 minutes or so SharePoint is looking for changes to libraries and lists in order to update the search index. When it spots a freshly populated site column. It kicks off a separate task to generate managed properties for that column. This task runs on a schedule that we cannot influence. Sometimes 15 minutes is all it needs to create the managed properties sometimes 24 hours.

Once this task completes the values in the column will be discoverable by search with new items discovered and added to the index every 15 minutes or so. If you’ve used the site column to tag documents in a library, you’ll now be able to use those tags in search. Thereafter we are into the realms of display templates and refiners if the OOTB SharePoint results do not present the results in the format you need.

If you are interested in the behind the scenes magic then check out this post “From site column to managed property – What’s up with that?” – the post and the series of posts it belongs to has been an invaluable reference for me on my SharePoint journey.

 

Advertisements

Reusable columns

The aim of this solution is to demonstrate how to create a reusable column that you can assign to multiple lists and libraries.

Reusing columns is useful if you want to establish a consistent definition across lists and libraries. You can share the definition across multiple lists and libraries so that you don’t have to recreate the column settings each time. A significant additional benefit is that when items are added to a reusable column they discoverable through search (the magic only happens after it has been populated). Reusable columns are called site columns in SharePoint. Site columns can use any of the available column types, including managed metadata, but be careful if you are using them as the source in a lookup function as you can only use either a single line of text, number or date and time as the source!

This solution works for both lists and libraries but it is limited to the scope of the site i.e. a site column in one site collection cannot be used to augment a list or library in another site collection unless they are published by a SharePoint Administrator as part of a tenant wide content type.

For this solution I’ll use the example of where we have number of projects nested under a master project and each one needs a list that contains a definition of the project.

heirarchy

As there are a number of projects we need to ensure that the information being captured is consistent. Each site will contain a list to capture the following Project details:

  • Project number
  • Title
  • Description
  • Principal
  • Manager

The steps in this solution are:

  1. Create site columns for each field
  2. Create a list
  3. Attach the site columns to the list
  4. Modify the list view

Those of you who are familiar with SharePoint might notice that the solution does not include the use content types. Using content types to optimise reuse and search queries is the natural conclusion to the reuse story. I felt that by including a section on content types would make this solution overly long and it is not always necessary to use a content type e.g. where you need to add a searchable column to a single list or library and are happy to add it to an existing content type.

The methods in this solution can be applied whenever you need reusable content in your SharePoint site.  You’ll need the design permission level or higher to implement the solution. If you are creating columns for reuse throughout your SharePoint environment you will need permissions to work with content type hub.

1.    Create site columns for each field

Site columns are created from the site settings page. The site columns item is located under the “Web designer galleries” heading.

Cog > Site settings > Site columns

Site columns are organised into groups which makes it easier to find them when it comes to reusing them. We will create our columns in a new group which we will define when we create the first column.

It is good practice to use short names (lower camel case) and omit spaces when defining site columns, lists, libraries, or sites as SharePoint will use the name as it’s internal name. The internal name is fixed from the time of creation and cannot be edited. If the internal name is long and or contains spaces, you might run into difficulties when trying to reference or rename it. For example, if you create a site column with the name “DC Project technology” the internal would be “DC%5Fx0020%5FProject%5Fx0020%5Ftechnology”  ! It is possible to rename site columns, lists, libraries, or sites after creation to use spaces, long names etc. The act of renaming preserves the internal name and applies a display name as a mask. This means you could repurpose a column or rename it without changing any wiring that depends on it.

For this solution we will create 4 columns and once created rename them:

table

I’ve assumed that the Project number will be a whole number. If it is a combination of letters and numbers, then you’ll need to use the “single line of text” column type. You’ll notice that a column called “Title” is missing. Every list includes a title column by default and in this solution we will use that to hold the Project Title. In other solutions you might not use the title column. If that is the case, then do not delete it!  Remove the requirement for it to be completed and consider hiding it in views. Be wary if you hide it as users will lose access to the ellipses … right click menu for each item.

As mentioned earlier, when we create the first column we will also create a group. The group is a visual aid and so you do not need to worry about an internal name for it.

4a

We start the process by selecting Create column which is located immediately below the page title. I’ll step through the detail of creating the first column which is then repeated for the subsequent columns.

Column 1 – Project number

1.       Enter the internal name prjnum as the column name

2.       Select Number as the type of information

I’ve assumed that the Project number will be whole number. If it is a combination of letters and numbers then you’ll need to use the “single line of text” column type.

When you select Number the page will reload changing the options available lower down on the page. You’ll see the same reload behaviour if you pick a different type of column.

It’s also worth noting at this point that certain column types cannot be converted to a different type once created. For example: single line of text, multiple lines of text, choice, number, currency and yes/no can only be changed to one of the other listed types e.g. single to multi line and not to a (then) unlisted type like Lookup. Also certain column types like yes/no do not work with lookup queries.

3.       Select New group and enter Project

4.       Add some helper text to the Description field

You’ll notice that I have left “Require that this column contains information” set to No. By setting this option to Yes it is possible to enforce the use of unique numbers in the Project number column but SharePoint will strictly enforce the uniqueness which means mistakes are really hard to undo. I’ve found a more user friendly approach is to guide people to use one row in the list per project.

5.       Set the Number of decimal places to 0

The remainder of the options can be left as their default settings.

5a

Selecting OK creates the new column and assigns it to the Project group.

6a

The final step is to rename the site column to use its display name. The column can renamed by clicking on the column name, editing the column name, scrolling to the bottom of the page and selecting OK to save it. SharePoint will then return you to the site columns page

Before (note the reduced list of types of information)

7a

After

8a

When you select OK you might be presented with a warning message which is fine to accept by selecting OK.

9

Selecting OK will save the column and SharePoint will return you to the site columns page.

If you return to edit mode, by locating the column in the list and selecting it, you will see that the value for field name (or internal name) is reported in the address bar:

10a

The next steps are to repeat the process for the remaining columns (remembering to create them with their internal names first) and assign them to the existing Project group rather than creating a new one.

11a

Column 2 – Project description

I opted to use plain text for this column as I felt additional features like hyperlinks where unnecessary.

12a

Column 3 – Project principal

There are options for items using the “People or groups” type of information. Several like Name (with Presence) come with additional data that introduces unnecessary complications for this solution so I opted to use simpler the Name choice.

13a

Column 4 – Project manager

As for the Project principal, I opted for name only.

14a

The next step is create the list to hold the Project details.

15

2.    Create a List

With the site columns created the next step is to create the list that will ultimately hold the project information. You can have multiple instances of the list throughout the site collection (and it’s sub sites). If you plan to have a large number of lists then I recommend using content types to further optimise the deployment. There are several locations in a site from which you can create a list – the screen shot shows just one of them.

Cog > Add an app

16a

From the gallery we need a Custom list

17a

When naming a list for the first time it is good practice to give the list a short name and then rename to use a display name.

18a

Select Create and after SharePoint has created the list it will take you to the site contents page.

19a

With the list created it is now possible to rename it so it uses a display name. The list name can be changed by accessing the list settings. Select the alongside the list name and then Settings

20a

From the settings page we need List name, description and navigation which is the first item under the “General settings” heading.

21a

Before

22a

After

23a

Apart from the changing the name it is a good idea to add this list to the “Quick launch”.

Select OK to save and SharePoint will return you to the settings page.

Versioning is not enabled by default for lists. It is a good idea to use versioning on this type of list so changes can be tracked. Once you have saved the changes to the list name you will be returned to the settings page. From the settings page we now need Versioning settings which is the second item under the “General settings” heading.

24a

Before

25a

After

26a

To add versioning, it is only necessary to change the “Create a version each time you edit an item in this list” to Yes. If you need changes to this list to be authorised, then you could consider enabling Content approval (but be prepared for the friction this option will generate) and change the Draft item security. We do not need to worry about discarding versions or item visibility.

Select OK to save and SharePoint will return you to the settings page. The next step is to add the site columns to the list.

3.    Attach the Site columns to the list

With the list configured it is now time to add the site columns to the list. Hopefully you are still on the list settings page (if not now is the time to find your way back to it!). From the settings page we need Add from existing site columns which is located in the “Columns” section.

27a28

From this page you can add any available site column. We can refine the list of available columns by selecting the Project group from the “Select site columns from” drop down.

29a

Now a tip is to add the columns in the order you want them to be displayed in the list (do not worry if you do not do this as you can reorder them at any time). This order will be the default column order and we’ll tweak it in the final step to include the Project title. For our list we need to add all four columns and you can add them either one-by-one by selecting each one and then Add > or selecting all of them (pick the first column, press and hold shift, pick the last column) and then Add >.

30

Select OK to add the columns and SharePoint will return you to the settings page. The final step is to modify the list view to present the columns in a logical order.

4.    Modify the list view

With the list configured and columns added it is now time to modify the list view to present the columns in a logical order. Hopefully you are still on the list settings page (if not now is the time to find your way back to it!). From the settings page we need Column ordering which is located in the “Columns” section.

31a

We are changing the order in the list Settings as this is the baseline order presented in the New Item form. It controls the top-down presentation whilst the settings in a particular view affect the left to right presentation. We will still create views and reorder them but this helps as it speeds up the editing process and encourages logical relationships (which is good for the user experience e.g. the Project Number will normally appear above the Title in any form the Manager will always be below the Principal once we have set them).

Before

As I had previously added the columns in order, I only need to move the Title column to after the Project number.

32

After

To move a column simply change the position number in the drop down alongside it. SharePoint will then renumber the columns based on the move. In my case I changed the Project number from position 2 to 1. The result was that SharePoint changed the Title position to 2 and with the remainder unchanged.

33a

Select OK to save the change and SharePoint will return you to the Settings page.

34a

The top down column ordering is respected in the New Item form.

36

Whilst we have changed the column ordering it is not reflected in the list view.

35

The column ordering controls top down presentation. The list view controls left to right presentation. The final step in this solution is to edit the All Items view (which is the out of the box default view). As you can see this view show all columns we need but in the wrong order. The view can be configured from several locations including the Ribbon (in the classic list view), Command Bar (in the modern list view) and the list settings. In the list settings select the view name to access its configuration.

37a

Before

Whichever route you take to access the list view, you’ll end up here.

38

After

39

The list is now configured and ready for use.

40

 

That’s it nothing more to do but add content. I hope this solution has given you an insight into the configuration and use of reusable columns.