How to create a custom ID for lists and libraries

In this example I demonstrate how to create a simple solution that allows users to submit a request to a list, then a workflow fires that updates the request ID field with our custom ID number.

ID numbers, reference numbers, ticket numbers…this is something that regularly gets asked to be a part of any SharePoint solution or request based system. My first thought when this is required is “easy, we can just use the SharePoint item ID column and use that”. However, creating a simple calculated column that leverages the in-built ID column is not as easy as it seems.

My first attempt at creating a custom ID column involved creating a new calculated column, and appending some text before the ID and then inserting the ID column into the formula, like this:

="REQ-00"&[ID]

The problem with this approach is that when new items are added, the ID appears to “slip” resulting in the custom ID column having no ID number being pulled from the SharePoint ID.

Custom ID column – modern SharePoint

1. Pre-requisites

Before you begin you will naturally need to create either a list or library in SharePoint, and the relevant apps checked as part of your O365 license.

2. The setup

  • Create a new column, with the type Number – I called this ‘solIncrementNum
  • Create a new column, with the type Calculated – I called this ‘solReqNum‘, later renamed ‘Request Number’
    • In the formula field, add the following: ="SOL-00"&[SolIncrementNum]
    • For the Data Type, select Single line of text
Setting the formula for the solReqNum column in list settings

NOTE: for the Request Number formula if you want to prefix your custom ID with something else just replace what’s between the ” “ in the formula field above.

3. Build the Flow

Flow action: when a new item is created

  • Create a new flow from the template “when a new item is created, complete a custom action”
  • Give your Flow a name, I called mine “Populate Solution Request Number”
  • In the “when a new item is added” step, make sure the site address and list name are the same as the list you built the custom ID column for earlier
Step 1 of the Populate Solution Request Flow

Flow: update item

  • Press + New step, start typing “update item”, select the update item action from the selection
  • Select the site in question, then copy and paste the List Name from the previous action
  • Make sure this action has the following fields set:
    • Id: ID
    • Title: Title
    • solIncrementNum: ID

NOTE: make sure that when you set these fields, that the values you use are coming from the “when a new item is created” action.

Step 2 of the Populate Solution Request Flow

Now when new items are created within the list or library, the flow will fire and create a new request number.

Modern SharePoint list with Flow that populates Request Number

How to set the default value of a lookup field

(this post was written using a SharePoint 2010 environment)

If you are using lookup columns in your SharePoint environment, one thing you may want to do is set the column that appears first, or is the default value in the lookup list when a document is uploaded into a library.

Now this solution is not a no code solution, but it requires very little code and is really straight forward to read and understand…

Step one – prerequisites

My setup to achieve this contained the following:

  • A custom list with each lookup value as a seperate list item (name stored in Title column)
  • A document library with a lookup column looking at the title in the custom list

Step two – configure the edit form

  • Open the list which is using the lookup column, make a note of the display name of the column

NOTE
This caught me out while configuring, I naturally took the field name of the column from the URL string as opposed to the column name displayed in the edit form, make sure you use the latter as the field name won’t work.

  • Navigate to the lookup list where the lookup column is pointed to
  • Open the item in this list that you wish to be the default value
  • Open an item in a new window, in the address bar look for ID= and make a note of the number value as this is used for later
  • Navigate to the libraries edit form (just add /Forms/EditForm.aspx after the name of your list or library)
  • Press Site Actions > Edit Page
  • Add a web part > add a content editor web part to the page
  • Click inside the content editor web part > Under Editing Tools > Format Text press the HTML, Edit HTML Source button

Step three – add the code

  • In the HTML Source window, paste in the following:
<script src="https://code.jquery.com/jquery-1.11.0.min.js"> </script>

<script type="text/javascript">

$(document).ready(function() {

$("select[Title='lookup']").val('1');

});

</script>
  • You will need to change the [Title=’lookup’] to be the name of the lookup column as described earlier
  • You will also need to edit the number after .val to be the ID number of the lookup list item we made a note of earlier
  • Under the Page Tab > Press Stop Editing, make sure to save your changes

Test your changes!

Now when you upload a new document, your lookup column will default to the value we have specified!



How to group by date chronologically for library views

(this post was written using a SharePoint 2010 environment)

So here’s the scenario, we have a document library that contains agendas, minutes, reports and other files related to meetings. The document library has a custom column called ‘Meeting Date’, a date column that is mandatory for all files that are uploaded.

We are required to create a view that is grouped by meeting date, sorted chronologically. Let’s give it a go!

Step one – prerequisites

My setup to achieve this was as follows:

  • A document library
  • An additional date column ‘Meeting Date’

Step two – configure the library

  • Navigate to the document library
  • Create a new calculated column called ‘Month of Meeting’
  • In the Formula section, add the following:
=IF([Meeting Date]="","Empty",("0"&MONTH([Meeting Date])&"/"&RIGHT(YEAR([Meeting Date]),4)))

NOTE
This formula basically states that if Meeting Date is blank, show Empty, if the meeting date has a value format it as MONTH (0 in front of the month number) / YEAR (yyyy).

  • Make sure the data type returned is ‘single line of text’
  • Press OK

Test your changes!

Now we have created a calculated column, we can test our changes by adding the column to a view and checking the Month of Meeting column has values.

Step two – create the view

Now we have verified our formula is working, we can start building out our view based on the requirements.

  • Navigate to the document library
  • Under Library Tools > Library > Create View
  • Scroll down to Group By, then group by Month of Meeting in ascending order
  • Press OK

NOTE
In the Group By section, you can set whether the groups are open or closed by default by choosing either collapsed (closed), or expanded (open).

You can also change the default number of groups to display from 30, but beware of slower page loading if you set it too high.

Now our view is configured we can take a look at it in all its chronological glory!

If you want to find out more about using group views, take a look at another post I wrote on ways around the 10 item limit in choice columns.

Configure a default view for Document Sets

(This post was written using a SharePoint 2010 environment)

Document sets are a pretty awesome way to convert people from traditional folders to using metadata in SharePoint, but retaining the ‘feel’ of a nice folder structure.

When you start using document sets you might want to play with the default view of your files, this isnt as straight forward as just setting a new default view. Here’s how to do it

Create and configure the view

  • Create your view
  • Under Folders > ensure show this view is set to In folders of content type: document set
  • Press OK
Select the document set content type in the view settings

Select the view for the Document Set Content Type

  • Navigate to the Library Settings
  • Under Content Types Select the Document Set
  • In Settings > Select Document Set settings
Document Set settings
  • Under Welcome Page View > select your view
  • Press OK

Now the changes made to your custom view will be present inside each document set!

Bonus

For more on document sets, check out my write up of the quirks of document set routing.

How to show the folder path of a file in library views

Introduction

Firstly, I want to make a mention to this great blog post by Tom Benjamin for giving me the direction as to how to achieve this. His post is way more complex than what I was looking to do, so if you want to find out more about how to show files from a folder using CAML queries take a look:

Link: https://www.tombenjamin.ca/blog/designer/view/using-caml-query-show-files-folder/

The scenario

A common request I get is:

How do I see what folders/ sub-folders my files are in at a glance

– all users everywhere

Out of the box, there aren’t any columns available that you could potentially leverage to display this information in a standard SharePoint 2010 library.

The solution

So, just by adding one value in SharePoint Designer, here’s how you do it:

  • Navigate to the library you wish to change, create a new view under Library Tools > Library > Create View
  • Choose the relevant format of your view, give your view a name and press OK
  • Open SharePoint Designer > Open the site > open the library you were just working in
  • In the Views pane > click to open the view you just created
In SharePoint Designer, clicking on the view name will open the view in edit mode
  • In the code editor window, scroll down until you see something like the following:
<ViewFields>
	<FieldRef Name="DocIcon"/>
	<FieldRef Name="LinkFilename"/>
	<FieldRef Name="Modified"/>
	<FieldRef Name="Editor"/>
</ViewFields>
  • Add the following field reference in between the opening <ViewFields> and closing </ViewFields>
  • Add the field reference in the display order you would like it to appear in the view
Add the field reference to the View Fields list
  • Press the Save icon to save your changes
  • Press the Preview button to see your view in action in the browser

Now you will notice there is a new column being displayed “Path”, that is showing us the full location of the file or folder in the libary. You’ll also notice that this path will display data when at the library root, or in any folders or sub-folders in the library.

Library root displaying a files path
File in sub-folder displaying relative location

Bonus

Taking this one step further, what if we wanted to show files of a certain type, then create a view that groups these files by their folder location? Guess what, that’s exactly what I did!

  • Navigate to your library > create a new view as before, this time base your new view off the one you just created
  • If you wish to only show files of a particular type, use the filter by settings (for example below is filtered to only shows Word documents)
  • Make sure “show all items without folders” is selected
  • Press OK
Filtering to only show word documents, also showing items without folders
  • Back in SharePoint Designer > Open up the view you just created
  • Scroll down until you see the opening <Query> tag and add the following beneath it:
<GroupBy Collapse="FALSE" GroupLimit="30">
	<FieldRef Name="FileDirRef"/>
</GroupBy>

Save and preview your view, it should now be grouping by the Path field:

I know this has proven really useful for my company, so hopefully this helps out someone else too 🙂


Problems creating list or library views based on created date

The situation

Data retention and deletion…I’m sure this is a something that anyone involved in Office 365, SharePoint on information management in general gets fed up of saying since the recent GDPR legislation!

Recently we have been rationalising and cleaning up our data in preparation for moving to Office 365. We are starting with SharePoint as the first target repository or silo of content.

The general consensus is to delete files and folders over 7 years old unless there is a pre-existing data retention policy to adhere to. So the next task is to identify those files that fall within our threshold, and ultimately delete.

Luckily, we have Tree Size Pro and ShareGate so I was able to relatively easily identify the files in question (there were a lot!).

The setup

As our SharePoint environment is a) rather full; and b) rather old, I made the decision to incrementally delete files rather than en-masse to mitigate risk, targeting the lists/libraries containing the most out of date content. I started by creating a view in the first library – library A with the following parameters:

  • Standard library view
  • Filtered by Created Date if less than or equal to 01/01/2011
  • Folders or Flat: Show items inside folders
    Show this view: In all folders

(all other settings are left default)

Results this returned looked good, I could see folders and files in this view that matched the criteria – brilliant! Based on my previous statement I decided to delete in batches out of working hours, again to mitigate risk. I deleted first from library A, then from the first stage and finally from the second stage recycle bin all in this fashion.

The problem

I had permanently deleted around 50% of the total volume of content to be deleted from library A when we started to receive reports of current files being ‘missing’ from library A…not a good day.

After these reports were investigated they were indeed true. It turns out that when folders are included within a library view, folders that match the filter will be shown in the view, regardless of whether the files inside match.

We tested the view exluding folders and all the files returned matched the filter criteria. The same results were demonstrated from a SharGate report of the same nature. The report of all files over 7 years old brought back folders over 7 years old, but they also contained files that were newer.

Conclusion

At present, we are not entirely sure as to why these filters are not able to drill down past a top-level folder. It appears to be difficult to specify via view settings to only show files within folders, including the folder itself that matches the criteria.

We have decided to omitt folders from our reports and views going forward and to solely focus on files as this is the most reliable way we can delete files.

Bonus: for those of you with ShareGate, heres an example of my report we created to bring back all files over 7 years old, excluding folders. I ran this report across the entire intranet application over a weekend and it worked a treat 🙂

SG-report

Fix pages with no publishing options in SharePoint

(This post was written using a SharePoint 2010 environment)

So you’ve got a SharePoint site, it all looks good (well, as good as it can!) but you notice that the Publish tab isn’t available in the ribbon.

First things first you check the site settings to see if SharePoint Server Publishing is turned on.

SP2010-publishing-feature.png

If you get to this point and your still no further forward it’s likely that your site wasn’t set up as a publishing site, but if you follow the steps below and your pages will be able to be published in no time.

  1. Open the site in question, then go to Site Actions > View All Site Content
  2. Open the SitePages library
  3. Under Library Tools > Library, select Library Settings

    SP2010-librarysettings
  4. Under General Settings > Versioning Settings, turn on Create major and minor (draft) versions > press OK
    SP2010-versioning

  5. Go back to the original page, you will now see the publishing tab has appeared!

Microsoft 365 update for February 2019

Take a look at some of the best bits for the improvements and enhancements to Microsoft 365 throughout February:

SharePoint

SharePoint Migration Tool updates

The SharePoint migration tool now supports migrating content types and managed metadata term stores for SharePoint Server 2013. Global tenant admin permissions are required to do so.

Also, many of the on-premises SharePoint web parts can be migrated into Microsoft 365. Examples being blogs, chart viewer, content search, list form, list view media plus many more.

You can now pretty much migrate every element of a SharePoint site that is most important to you such as web parts, pages and site navigation.

Find out more: full list of supported web parts 
Find out more: new and improved features of the SharePoint Migration Tool

Drag and drop to re-order the left-hand site navigation

You can now re-arrange the order of your site navigation elements with a nice, user friendly drag and drop gesture. This removes the multiple clicks involved in he ellipsis, move up or down options of old. This new gesture also works for dragging/dropping into a sub-navigation location.

Drag and drop the left-hand site navigation

Bulk check in/out

This one I’ve been waiting for awhile for! You will soon be able to check in/out multiple files at the same time form the modern ribbon in a document library.

Bulk check-in/out documents from a modern library

File signals

File signals or status icons are being added into SharePoint to add visual clues regarding the status of a file, such as check-out status, sharing, DLP blocks or missing metadata. This applies to modern lists and libraries.

File signals give visual clues regarding the status of a file

Column totals

A revamp of an old favorite, column totals and subtotals are coming to modern lists and libraries. These totals and subtotals are displayed in the footer. This is a welcome change from the old total count in classic views!

Modern column totals

Add columns between columns and drag and drop

You can now insert new columns in place between existing in and modern list or library view, plus move a column around by simply dragging the header to a new location in the view.


Adding a column between an existing column in a modern SharePoint list or library

Smarter file hover cards

The file hover card gives you a sneak peek into your most important files. Now, as soon as your hover over a file you will be able to see important stats like number of views, who’s viewed and who’s modified. This functionality is now being extended to almost all file types.

This new experience will also appear for files listed in your Shared by Me view.

Find out more: file hover cards are getting smarter and is now available for all file types!

Hover over a file in a SharePoint library or OneDrive folder to see more information about a file

Microsoft Teams

Priority notifications and message delegation

Priority notification alerts will notify a recipient to an urgent message on their mobile and desktop devices and repeat the alert every two minutes for up to 20 minutes, until a response is received.

Priority notifications in Teams

Also coming soon is message delegation. Message delegation enables a recipient to delegate messages to another colleague when they are unavailable.

Message delegation in Teams

Priority notifications are currently in private preview.

Find out more: New capabilities in Microsoft 365 empower healthcare professionals

Microsoft Authenticator

Microsoft Authenticator allows you to receive security notifications for important events on your personal Microsoft Account. When you receive a notification, you can quickly view your account activity to take action if needed.

Microsoft Authenticator can be used to add two-step verification for added security if needed. It supports fingerprint, face ID or PIN authentication.

Microsoft Authenticator

Find out more: Microsoft Authenticator app now sends security notifications

Links and resources

Ways around the 10 item number order limit in choice columns

I was recently updating a view in a SharePoint List, the view was set up to use metadata fields to sort and group the content…lovely stuff. What I was required to do was to implement a choice field with a numerical order within it (i.e. 1. First step, 2. Second step, 3. Third step).

With sort order in List/Library views, it works with either alphabetical or numerical options ascending or descending. What I found was with choice fields operating as the number order, once you hit 10 the numbering system went out the window!

What you end up with is something like this:

1) First choice
11) Eleventh choice
12) Twelfth choice
2) Second choice
3) Third choice

and so on…

By default, SharePoint interperates the choice field as alphabetical so the way I got around this was to just use:

a)
b)
c)

This gets around any issues with numerical values over 10 or having to create lookup lists or anything else 🙂

How to find open with explorer in modern SharePoint libraries

Explorer view in classic SharePoint sites has been a widely used bypass for users actually interacting with SharePoint libraries for a number of years.

Now in some cases that’s for good reason, from being able to upload multiple files easily in older versions of SharePoint to a familiar navigation of nested folder structure.

With modern SharePoint libraries, the old school ribbon has gone the way of the dodo…and so it seemed had open with explorer.

But fear not! If you still use IE you can still use the trusty open with explorer

How to open with explorer

  • Go to the library that you wish to open with explorer
  • On the right-hand side, press the drop-down icon next to all documents
    all-documents2.jpg
  • Press View in File Explorer
    file-explorer

Some weird stuff will then happen, where a classic 2013 version of your SharePoint site/library will open in a new tab and for me I got a message at the bottom of the browser window to allow popups from Microsoft then got another, more serious popup like this (multiple times):

IE-security

I pressed allow to all of these then voila! we have file explorer!

PLEASE NOTE:

File explorer only works for Internet Explorer, I tested in IE11 and it categorically doesn’t work in Firefox, Chrome, Edge or Edge Dev (beta).