SharePoint Online – Picture Column and Column Formatting

I had earlier blogged about Microsoft Rolling out column formatting to the first release tenants and how it could be useful in many scenarios.

For anyone who wants to get started with column formatting following article is by far the best technical documentation.

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

Today I am going to talk about one specific scenario where you could use column formatting.

Let’s assume that you want to create a picture column in SharePoint to show some sort of status progress. I know we can achieve this in many ways but just for the sake of this blog post we are going to assume that you have a column in your list/library of type Picture.

Now in SharePoint Online when you have a picture column and you insert the URL of the image in that column it displays the image. This image is clickable and when you click on that image it opens the new tab with the image displayed.

This behavior may work in some scenarios but in our case since we want to use this picture column just to show the status progress we do not want that image to be clickable.

We can use column formatting for this. Follow the steps below to make that image not clickable.

  • Open context menu on your image column and select à Column Settings à Format this column.
  • This should open JSON editor on right hand side.
  • Paste the following code in the editor and click Save.
{
    "elmType": "div",
    "children": [
        {
            "elmType": "img",
            "txtContent": "",
            "style":{
                "min-height": "initial",
                "margin-top": "0px"
                                },
            "attributes": {
                "src": "@currentField",
                "width": "100%"
            }
        }
    ]
}

As you can see I am not doing anything extra ordinary. I am simply displaying the same image without anchor link. If you follow the article that I have linked above you would be able to figure out it’s straight forward.

One thing that I needed to do on top of that is to add couple of styles. Since when you use column formatting it uses its default class and that makes your image smaller and aligns it to the top.

I have set min-height and margin-top attributes to align images properly with the list item as well set the width to 100% so it does not shrink the image.

I hope this helps to get started with the column formatting.

In the next column formatting article I will cover how to make image clickable using the URL from the different column.

SharePoint Online – Column Formatting – Using different columns

I had earlier blogged about Microsoft Rolling out column formatting to the first release tenants and how it could be useful in many scenarios.

For anyone who wants to get started with column formatting following article is by far the best technical documentation.

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

Today I am going to talk about one specific scenario where you would want to use other fields data on the current item.

Most column formatting examples you would see are based on the current column where you could refer the column using @currentField. In some scenarios you would want to leverage other field values in the same item. e.g. If column X value is Y then change the background color of my current column.

So for this example I am going to have two columns i.e. Picture Column and HyperLink column.

What I want to do is when my items are displayed picture is clickable and it opens a URL in your HyperLink column and opens in a new tab.

Here is code.

{
 "elmType": "a",
 "attributes": {
 "href": "[$HYPERLINK_FIELD_NAME]",
 "target": "_blank"
 },

"children": [ 
 {
 "elmType": "img",
 "txtContent": "",
 "style":{
 "min-height": "initial",
 "margin-top": "0px"
 },
 "attributes": {
 "src": "@currentField", 
 "width": "100%"
 }
 }
 ]
}

Here I have element type <a> and then I am using element type <img> as the children. Most of the image element stuff you see around style is just to align it properly.

The key thing is element type <a> where I am setting href to other HYPERLINK column value and I reference that column by using the [$FieldName]. The column is formatted within the context of the entire row. You can use this context to reference the values of other fields within the same row.

I hope this helps.

SharePoint Hub Sites – New way to organize your intranet

During Ignite 2017 Microsoft announced Hub Sites. Just to recap Hub sites provides following capabilities.

Cross-site navigation
Content rollup
Consistent look-and-feel
Scoped search

Today Microsoft announced that they are starting to roll-out the hub sites. Here is the screen shot from Microsoft Official blog post about this event.

https://techcommunity.microsoft.com/t5/SharePoint-Blog/Organize-your-intranet-with-SharePoint-hub-sites/ba-p/174081

First question that comes to mind is how do I use Hub sites with my existing SharePoint sites.

Currently you can convert existing communication site or modern team time into a hub site. Microsoft’s recommendation is to select (either existing or new) communication site as the hub site. Once a hub site is created, approved site owners can associate existing team sites and communication sites with the hub site.

You will need to use Register-SPOHubSite PowerShell CMDLETS to enable the Hub Site. You must be a SharePoint administrator or above in Office 365 to create SharePoint hub sites. Site owners can associate a SharePoint site with a hub site that already exists.

There is Ask Me Anything Hub Sites happening and I encourage everyone to join and ask any questions that you may have.

https://techcommunity.microsoft.com/t5/SharePoint-AMA/bd-p/SharePointAMA

This is pretty exciting announcement as first release tenants will have Hub Sites available in next month or so.

 

Microsoft Teams – Managed Path for SharePoint Site

When using SharePoint online you would have noticed that you can create sites under /Sites or /Teams managed path. This is fine when you are creating classic sites where you can pick your managed path.

When creating modern sites you do not have option to select the managed path and it is always defaulted to /Sites managed path. This behavior is exactly the same when you create a new Team using MS Teams. When you create the new Team it creates the Office 365 Group as well as a brand new modern SharePoint site. This site is also created under the /Sites managed path.

What if you wanted to create all your teams connected SharePoint sites under /Teams managed path? Well it is possible as long as you want all your SharePoint sites gets created under /Teams managed path.

There is a setting in SharePoint Admin Center which allows you to select default managed path.

Go to your SharePoint Admin Center and click Settings.

Under Settings, scroll down to site creation section and there you would see that you can set the managed path for the new site that gets created.

Now there is another gotcha here. This would only work if you have your Self Service Site Creation setting is set to “Show the Create Site Command to user who have permission to create sites”. The moment you choose “Hide the Create site command” option, section which allows you to set the managed path is not visible.

I really wish Microsoft would allow two things here.

  1. Allow me to add more managed paths
  2. Allow me to set the managed path for SP Sites that gets created as part of Teams. Probably a setting on the Teams Admin page.

I understand there is not much flexibility here but I hope this help someone.

SharePoint Online – Column Formatting rolling out to first release tenants

At Ignite 2017 Microsoft announced the Colum Formatting feature in SharePoint Online. You can check out the awesome session on Channel 9.

https://channel9.msdn.com/Events/Ignite/Microsoft-Ignite-Orlando-2017/BRK3252

Microsoft have started rolling out the column formatting feature to the first release tenants. For anyone who did not hear about column formatting, it helps customizing how SharePoint list columns gets displayed.

If you are currently using SharePoint on-premises then it is like JSLink. Not exactly the same but you can achieve many formatting options using column formatting. As a matter of fact there is git repo for the column formatting samples. Check them out below.

https://github.com/SharePoint/sp-dev-column-formatting

To use column formatting you can go to your SharePoint list column and select “Format this column” under “Column settings”.

This will open a “Format column” window on the right where you can paste your JSON and either click Preview to see the changes or click Save to apply the changes.

If there are any syntax errors then you will get the error notification on that screen so you can correct the error.

Anyone who can create and manage views in a list can access column formatting from the column settings.

For anyone who wants to get started with column formatting must check the following article out as it has all the details you need to know about column formatting.

 

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

 

I will cover some examples that I have used in my next blog post.

SharePoint Communication site pages in Microsoft Teams

For anyone that is living under the rock, in May last year Microsoft announced Communication sites. Communication sites are mobile friendly and allows users to communicate to people throughout the organization with beautiful, dynamic, mobile-ready communication sites and pages that keep everyone informed and engaged.

You can read more about that HERE and HERE.

While communication sites are awesome they are not Group connected sites. In many cases you would want to use Communication pages within your Team.

It is very simple to bring them to your Microsoft Teams.

  1. Go to Microsoft Teams and click Add a Tab (+)
  2. Click WebSite under the various options.
  3. Give tab a name and paste the URL and select if you want to share that message in your Team channel.

  4. Click Save and you should see the communication page shows up in your Team Tab.

 

 

Teams is smart enough to trim all the additional SharePoint controls and display only the page in the Teams teab.

This is one of the awesome feature and I cannot wait to start integrating MS Teams and communication pages.