How to create one-click, direct download links in modern SharePoint Online libraries

I previously blogged how to create one-click direct download links, but that post was exclusive to the classic experience in SharePoint (or any opportunity in which we could use classic html/css).

Normally, to download a document in modern SharePoint Online libraries, we would have to use a file’s menu (right-click or ellipsis) then choose Download.

Click to enlarge

I was recently challenged to help figure out how to create a single click experience to immediately download a document in modern SharePoint Online libraries and after much trial and error was able to do so using a little bit of JSON in a calculated column.

Here’s how to create a Download link column in modern SharePoint libraries:

1. Create a calculated column (Library Settings > Create Column) named Download and set its formula to =””

Click to enlarge

2. Copy and paste the following JSON code into the JSON formatting field of the calculated column settings.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "Download",
  "attributes": {
    "target": "_blank",
    "href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
  }
}

3. Set the new column to show in the default view so it’s visible in the library and click OK.

Click to enlarge

4. Return to your library, and test it out!

And if you want anonymous users to be able to use these convenient download links, be sure to share a FOLDER link with the anonymous user(s) so they will see the file in the library alongside the one-click download link.

Optional formatting of the Download link

And while I’m not a JSON expert, I did dabble a bit in stylizing the Download link so it would look a little bit better. You can add a little bit of style to the JSON to achieve a more button-like experience (or for the advanced among you, change the element to an actual button or download icon).

Here’s how you can get started stylizing the text link (see result at bottom):

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "Download",
  "style": {
    "background-color": "gray",
    "text-decoration": "none",
    "color": "white",
    "font-size": "14px",
    "padding-left": "5px"
  },
  "attributes": {
    "target": "_blank",
    "href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
  }
}
Click to enlarge

Optional usage of the file’s name instead of “Download”

One small change to the JSON will reference the file’s name for the link instead of using “Download” for all links. Then you could hide Name and just use your Download column.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "[$FileLeafRef]",
  "attributes": {
    "target": "_blank",
    "href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
  }
}
Click to enlarge

Getting Teams certified: My prep for the MS-700 and the exam guide that followed (Recording)

I was recently invited to speak at the SharePoint User Group of DC and shared some prep tips and exam prep book writing experience with attendees. Most of the session was advice, practice questions, and resources for the MS-700 Teams Administrator certification exam. The last 10 minutes or so, I discuss co-authoring the MS-700 exam prep book with my co-author and friend Peter Rising.

Scott Brewster, one of the group’s leaders, kindly recorded and posted the session to YouTube so you can watch the recording below.

Be sure to check out the SharePoint User Group of DC’s upcoming events here: SharePoint User Group of DC (Arlington, VA) | Meetup. You can also follow them on Twitter (@sug_dc).

What is Microsoft’s Imagine Cup?

food art hand pattern

This year I had the privilege of serving as one of 165 judges for Imagine Cup Junior 2021. Imagine Cup was new to me last year (2020), and I knew immediately I wanted to play a part in this amazing program. As a Microsoft MVP I was eligible to help and threw my name in the ring for judge selection for both Imagine Cup (collegiate division for ages 16+) as well as Imagine Cup Junior (ages 13-18). While I wasn’t selected as an Imagine Cup judge, I was thrilled to be asked to serve in the Junior division process.

“The Imagine Cup brings together student innovators using passion and purpose to tackle global issues with tech.”

https://imaginecup.microsoft.com/

Imagine Cup is basically a tech skills-based competition that not only has teams entering amazing projects and ideas in a bracket, but it serves as a learning journey as well. Teams are given resources, learning event opportunities, and information throughout the duration of the competition to help from beginning their Azure or other tech learning to completion of a robust and impressive project. The Junior division doesn’t actually build their solution, but proposes a comprehensive idea and often prototypes or videos to help illustrate the concept. The collegiate division, however, does actually build their project.

While both divisions focus on solving global issues using Microsoft tech, submissions and specific technology focuses may vary. For example, the collegiate division (Imagine Cup) this year accepted a broad array of team project submissions in the categories of Earth, Education, Healthcare, and Lifestyle. The Junior division (Imagine Cup Junior) focused the tech aspect specifically on AI for Good, and had categories of AI for Earth, AI for Health, AI for Accessibility, AI for Humanitarian Action, and AI for Cultural Heritage.

Check out the winner of the 2021 collegiate division competition, Team REWEBA from Kenya.

In the Junior division, there isn’t one winning team but a top 10. As a judge, I was asked to evaluate a group of submissions using a standardized rubric. I was so blown away by the ingenuity and compassion behind many of these submissions and am excited to see what these young innovators do next. The future is in good hands.

Check out the winning top 10 teams in Imagine Cup Junior 2021.

You can also check out the Imagine Cup FAQ to learn more and see contest rules.

How to enable and use audience targeting for SharePoint pages and news

anonymous person with binoculars looking through stacked books

Note: This article pertains specifically to SharePoint Online (M365).

Audience targeting can be used to surface relevant information and resources to specific groups of people throughout SharePoint. This post will focus specifically on enabling audience targeting on your site’s pages and news so that you can create individualized experiences for users based on their identity or role.

The overall process consists of three steps:

  1. Enable the audience targeting ability for all content in your Site Pages library.
  2. Specify the appropriate audience(s) for specific pages/news items within the library.
  3. Modify any existing web parts (news or highlighted content web parts) to enable audience targeting (simply meaning to utilize any audience targeting configurations that have been specified for the content surfacing in that web part).

Step 3 is not required if you only wish to have audience targeting “seen” on the SharePoint start page, mobile app, or other non-customized areas where news may surface.

How audience targeting works

If you specify an audience for content, it will be shown in relevant areas (SharePoint start page, mobile app, news or highlighted content web parts using audience targeting, etc.) to members of the audiences only. This is not a security feature – the content is still discoverable by other users – just not surfaced upfront conveniently for them.

If you are a member of an audience specified on a news piece, you’ll see that news wherever it’s being called up. If you’re not, you won’t see it but can still search or browse to find it.

If no audience is specified for an item, it will be shown to all users. Or if a web part (such as a news web part) has disabled audience targeting, any specified audiences on individual pieces will be disregarded and the content will be shown to all through that particular web part.

Here are the detailed steps to set up audience targeting:

Enable audience targeting for Site Pages (and news)

1. Go to your Site Contents > Site Pages library

2. Select the settings gear > Library settings

Click to enlarge

3. Choose Audience targeting settings

Click to enlarge

4. Check the box for Enable audience targeting and then click OK.

Click to enlarge

Specify an audience for SharePoint pages or news

1. Now return to your Site Pages library and select a page or news item to which you wish to add audience targeting.

Click to enlarge

2. Open the details pane (i icon) in the upper right

Click to enlarge

3. In the Properties section, enter up to 50 M365 Group names, user names or emails, etc. to whom the selected content should be targeted. Notice it also adds the specified audience in a column in the library. Your additions are saved automatically.

Click to enlarge

Modify web parts to utilize audience targeting where available

1. Edit the page on which you’ve placed a news or highlighted content web part.

2. Click the edit icon (pencil) on the particular web part for which you’re enabling audience targeting.

Click to enlarge

3. In the Filters section, toggle Enable audience targeting on.
(Note: News source must be This site or Select sites. Recommended for current user doesn’t have audience targeting settings).

Click to enlarge

4. Republish your page when ready.

This can take some time to fully update in your site, so check back after a while to confirm functionality.

After completing these three sections, you’ve now

  • allowed content within the pages/news library to be used in audience targeting scenarios,
  • chosen specific pieces to which you’ll apply audience targeting,
  • and modified the web parts where content will surface to utilize those pieces’ audience settings when appropriate.

Check out this article for more information on SharePoint audience targeting, including more than pages and news.

How to export OneNote to PDF while preserving clickable hyperlinks

person holding apple magic mouse

It’s not often I need to “print” OneNote. However, today I had a section I wanted to convert to a PDF document and printing is the way to go in OneNote for Windows 10 (the version that comes pre-installed on Windows 10 machines). I found, however, that the file created through this method didn’t maintain its links (links weren’t clickable in PDF).

After trying Adobe, SnagIt, and Microsoft PDF print abilities to no avail (using both OneNote versions – Windows 10 and desktop/2016), I found success using OneNote (desktop) > File > Export > PDF. Detailed instructions are at the bottom of this post.

Learn more about the difference between the two OneNote versions here.

Thankfully, OneNote (desktop aka 2016) allows us to “Export” notebooks, sections, or pages to PDF. We can print to PDF as well, but using “Export” specifically is the key here to maintain the clickable links. OneNote for Windows 10 doesn’t currently have a similar export ability.

If you don’t have OneNote (aka 2016) already installed, you can still download it here. Once you have it, proceed with the following steps to export your OneNote notebook, section, or page to PDF with clickable hyperlinks:

1. To open a new notebook, select File > Open. You may need to switch account if not seeing your cloud notebooks right away.

Click to enlarge

2. Once your notebook is opened and you’ve opened the specific content you wish to print, click File (upper left).

3. Choose Export > Content Scope (page/section/notebook) > PDF > Export as shown in the following screenshot.

Click to enlarge

4. Choose a location and filename, then click Save.

Click to enlarge

Now check the resulting PDF and you’ll find your OneNote notebook content with clickable hyperlinks in tact.

Bonus tip: One small thing to note is that OneNote for Windows 10 has a nice feature where you can print a section group. OneNote (desktop) does not – it’s only exportable by page, section, or the entire Notebook. So if you don’t need clickable links in the resulting PDF, you may wish to choose OneNote for Windows 10 for your “Print to PDF” needs to simplify printing several sections at once from the same section group.