Wednesday, February 27, 2019

Different ways to apply SharePoint field customizer extension to existing multiple columns


SharePoint Extensions can be deployed to SharePoint Online, and you can use modern JavaScript tools and libraries to build them. The Field Customizer Extension allows modifying the Views of the field in a list view. It can be used to override the field representation in the list. Field Customizer can be used with site columns or directly to the field inside a list. Microsoftarticle shows the detailed step to create the Field Customizer Extension but with limited instruction to apply it to existing list columns. Here are multiple ways to apply Field Customizer Extension to existing list columns.

The way to do this is to ClientSiteComponentId GUID attribute of Field Customizer for the existing field. There are few ways to implement this.

1. The first way is to use CSOM PowerShell to update ClientSiteComponentId attribute.

$siteURL = "https://mycompany.sharepoint.com/sites/Harry-PM-Testing"

$userId = "admin@mycompany.onmicrosoft.com"
$pwd = Read-Host -Prompt "Please enter your password" -AsSecureString
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId,$pwd)

$listTitle = "Order"
$existingColumnName = "SPFxExeColumn"
$ClientSideComponentId = "acd4d36c-a4ad-123c-a123-93862bd52123"

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$ctx.Credentials = $creds 

try{
    $lists = $ctx.web.Lists
    $list = $lists.GetByTitle($listTitle)
    $listItems = $list.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
    $ctx.load($listItems)
    $ctx.load($list.Fields)
    $ctx.executeQuery()

    $field = $list.Fields.GetByInternalNameOrTitle($existingColumnName)
    $guid = [GUID]$ClientSideComponentId
    $field.ClientSideComponentId=$guid
    $field.update()
    $ctx.Load($field)
    $ctx.executeQuery()

}
catch{
    write-host "$($_.Exception.Message)" - foregroundcolore red
}   


2. The second is to use REST API like mentioned here.

3. The third easiest way is to use the PnP PowerShell like below.

$siteURL = "https://ionisdevops.sharepoint.com/sites/Harry-PM-Testing"

$listTitle = "Order"
$existingColumnName = "SPFxExeColumn"
$ClientSideComponentId = "acd4d36c-a4ad-449c-a312-93862bd52376"
  
Connect-PnPOnline -Url $siteurl  

$guid = [GUID]$ClientSideComponentId
Set-PnPField -List $listTitle -Identity $existingColumnName -Values @{ClientSideComponentId=$guid} -UpdateExistingLists

You can apply the same Field Customizer to as many existing fields as you like as long as the field has all the required schema as the the original list. The fields do not need to be the same type like "Number" since it will not matter.


If you need to apply other SPFx extension like custom action to whole tenant, please refer to other blog.




Tuesday, February 19, 2019

Approaches to enable modern site experience at the root of a SharePoint tenant


After Microsoft release modern site experience, there is a request for existing customers to enable such modern experience at the root of a SharePoint tenant. There are two different ways at this time.  You might decide based on your urgency and requirement.

The first way is traditional way as described in here. The approach is to delete the root site and recreate it.

The second way is to use Microsoft PowerShell Enable-CommSite to convert to modern site. However, as of today the command is still not available globally.

If  enabling modern site experience at the root of a SharePoint tenant is not urgent, I would recommend you might wait for the PowerShell to be release.

Thursday, February 14, 2019

Procedure to add Full-width column SPFx webpart without fat banner, any horizontal margin or padding, or users' comments

Modern SharePoint pages support layouts that allow users to organize the information they present on their pages. When you add a custom webpart, the default behavior is like below screenshot.


There are some cases that users would like to have a pages modern SharePoint pages with custom SPFx webpart without fat banner, without any horizontal margin or padding, or users' comments as highlighted from the screenshot. This has been reflected in user voice. Here are the detailed steps to implement.

1. The first step is to remove the fat banner on the page like communication modern page. There are at least two different ways to implement this. The difficult way is to develop and deploy a custom SPFx webpart to hide it as described in Mikael Svenson’s blog.  Another easy way is to copy the home.aspx page and rename to your page. Then this page will NOT have the fat banner as described in Rajesh Sitaraman’s blog.

2. The second step is to implement the SPFx as Full-width webpart. This can be done quickly by adding the below configuration code to the YourWebPart.manifest.jason file\ as described in Microsoft’s blog.  

"supportsFullBleed": true,

Then you need to add this webpart as Full-width column webpart. You might need to go to the “Site Pages” library and then click “Site Page” on the ribbon in order to get the Full-width column webpart option for the page. Sometime you would not see Full-width column webpart option if you click “App Page”.

3. The third step is to hide the user Comments. This can be done quickly by following the instruction provided by Greg

The updated page with the same webpart now displays much clean as in the below screenshot.


4. The forth thing is to remove the "Feedback" button. This is similar to we described before to use SPFx webpart to hide it as described in Harjit’s blog

5. The final one is to remove the "Like" "Save for later" at the bottom of the page. We may also use SPFx with css to hide this as in previous session.

I've not implement step 4 or 5 yest but the page already look much clean. Hope this would help.



Wednesday, February 13, 2019

How Microsoft completely failed to protect SharePoint Online files with Office 365 labels and DLP


Microsoft provided a feature that users could apply Office 365 labels and data loss prevention (DLP) policies for SharePoint Online team sites with various levels of information protection. This looks exciting to design and deploy Office 365 labels and DLP policies for baseline, sensitive, and highly confidential SharePoint Online team sites highlighted in this Microsoft article.

One of the use case is to use SharePoint policy to label one document library as high sensitive and do not allow to share with external users. External users are no allowed to request access. After you configure the policy, the document in the library will have a small icon to indicate the policy. See the screenshot. This looks good so far.





However, after few days configuration, debugging, and discussion with Microsoft, this DLP feature seems to be funny and stupid that will fail completely! Here are few issues and I’ll provide the real life example to explain the details.

The first issue is after the label and policy applied, it may take one day to apply to SharePoint site and seven days to synced to the item. When you have policy enabled on the document library, any document uploaded will NOT have the policy until policy applied up to one day delay. In previous screenshot, you will see two documents do not have the policy applied at that time!

This is like a law officer like policeman add a "Stop" sign to the road. However, it will not take effect until a day later. Every new car arrived to this street will not see the sign until one day later. This is to every new car!!!

The second issue is user can edit the document properties and remove the label. See screenshot below.


This is like a law officer like policeman add a "Stop" sign to the road. However, driver can remove the stop sign! Every driver can remove the stop sign!!!


The third issue is user can edit the document properties and change the label to a different one event it is not assigned to this library. See screenshot above there are two labels.

This is like a law officer like policeman add a "Stop" sign to the road. However, driver can change it to a different sign like "Slow" sign! Every driver can change the sign to ANY other sign available!!!

Now you will understand why SharePoint Online files with Office 365 labels and DLP protection feature is so funny and stupid! I've raise the user voice in Microsoft user voice site.

Tuesday, February 5, 2019

How to fix SharePoint 2013 workflow missing issue on SharePoint online site?

If users could not find the out of box SharePoint 2013 workflow on SharePoint online site, here are two different ways to verify and fix the issue.

The first way is to click "Setting"->"Workflow Settings"->"Work Flows"->"Workflow Health" and then activate "The workflow service store feature" as described here.

If you would to fix on multiple site collections, here are the PowerShell script you can run against the site.

1. Install SharePoint online PnP PowerShell package.

Install-Module SharePointPnPPowerShellOnline

2. Check the WorkflowServiceStore site collection feature

Connect-PnPOnline -Url <Site URL>
Get-PnPFeature -Identity 2c63df2b-ceab-42c6-aeff-b3968162d4b1

3. Enable the WorkflowServiceStore site collection feature

Enable-PnPFeature -Identity 2c63df2b-ceab-42c6-aeff-b3968162d4b1 -Force

That's it.

Monday, February 4, 2019

Should we use Power or PnP PowerShell to manage the SharePoint hub site and association?

With SharePoint hub sit become available and more popular these days, there are some requests to create hub sites and associate some sites to the hub site. It would be idea to use PowerShell to automate the process. There are two PowerShell implementation, the regular SharePoint online PowerShell and PnP PowerShell. The difference of these two PowerShell has been described on Microsoft community.

However, when I try to use them and compare to the latest SharePoint tenant admin UI, both of them have limitation that would cause issues. I would like to explain the limitation and how to create hub sites and associate the site to hub.

The new SharePoint online admin has added a new feature that you could register the hub site through UI. It will allow you to enter the "Display Name" like "My Hub". The display name will be displayed in the UI and will be used in hub site association.




However, if you use PowerShell, there is no parameter we can pass the the command for "Display Name" . As a result, the hub site registered but it will not be easy to find from the SharePoint online admin center.

Another issue is the hub site created from PowerShell will take sometime like few minutes so the Add-SPOHubSiteAssociation command will not fail but will not associate the site to hub!

After working with Microsoft, there is a second PowerShell to set the hub site title. Here is the command.

Set-SPOHubSite -Identity <Site URL> -Title "My hub site"

At this time I'm thinking he best approach to manage the hub sites and association is like the procedure below.

1. Create hub site from using PowerShell
2. Set hub site title using using PowerShell
2. Associate the site with hub site from either SPO PowerShell or PnP PowerShell
3. Report the hub site and association from PowerShell.

Hope this would help.