Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

SharePoint Online: Apply JSON View formatting using CLI for Microsoft 365

SharePoint Online is a powerful platform for managing and sharing documents and other types of content within an organization. One of the key features of SharePoint Online is its ability to use JSON View formatting to customize the look and feel of lists and libraries.

However, applying JSON View formatting can be a time-consuming and repetitive task, especially if you need to apply the same formatting to multiple sites or lists. Fortunately, we have a command-line tool called CLI for Microsoft 365 that makes it easy to automate this process.

In my previous blogs we saw how to apply SharePoint online JSON view formatting using SharePoint REST API and PnP PowerShell. In this blog post, we will explore how to use CLI for Microsoft 365 to apply JSON View formatting to SharePoint Online lists.

The first step is to install CLI for Microsoft 365. You can do this by following the instructions on the official documentation page: CLI for Microsoft 365 – Installation

Then you can use below CLI for Microsoft 365 script to apply JSON View formatting to your SharePoint online list:

# Display name of SharePoint list
$listName = "Ganesh Sanap Blogs"

# Name of SharePoint list view
$viewName = "All Items"

# JSON to apply to view formatting
$jsonViewFormatting = @'
{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "additionalRowClass": "=if([$DueDate] <= @now, 'sp-field-severity--blocked', '')"
}
'@

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
   m365 login
}

# Apply JSON view formatting
m365 spo list view set --webUrl $siteUrl --listTitle $listName --title $viewName --CustomFormatter $jsonViewFormatting

Where [$DueDate] is the internal name of your SharePoint column.

Once you run above script successfully and navigate to SharePoint list view, you will see that new JSON view formatting is applied to your SharePoint online list view using CLI for Microsoft 365:

SharePoint Online modern experience to apply JSON View formatting using CLI for Microsoft 365
SharePoint Online – Apply JSON View formatting using CLI for Microsoft 365

Conclusion

Using CLI for Microsoft 365, you can easily apply JSON View formatting to your SharePoint Online lists, saving time and reducing the risk of errors. By following the steps outlined in this blog post, you can quickly get started with using CLI for Microsoft 365 to apply JSON View formatting to your SharePoint Online lists.

Learn more

sharepoint-online-apply-json-view-formatting-using-cli-for-microsoft-365

ganeshsanapblogs

SharePoint Online modern experience to apply JSON View formatting using CLI for Microsoft 365

SharePoint Online: Apply JSON View formatting using PnP PowerShell

SharePoint online JSON view formatting is a powerful feature that allows you to customize the look and feel of your SharePoint lists and libraries. In my previous article I explained how to apply JSON View formatting using SharePoint REST API. In this article, we will see how you can easily apply JSON view formatting to your SharePoint lists and libraries using PnP PowerShell from the command line.

The first step in applying SharePoint JSON view formatting using PnP PowerShell is to install PnP PowerShell module on your machine. To install PnP PowerShell, open a PowerShell console as an administrator and run the following command (or follow this article – Installing PnP PowerShell):

Install-Module PnP.PowerShell -Scope CurrentUser

For this blog post, we will use below view formatting JSON as an example:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "additionalRowClass": "=if([$PublishDate] <= @now && [$IsPublished] == false, 'sp-field-severity--severeWarning', '')"
}

If you use this view formatting JSON directly in below PnP PowerShell script, you may get errors like:

Set-PnPView: Name cannot begin with the ‘=’ character, hexadecimal value 0x3D.

OR

Set-PnPView: An error occurred while parsing EntityName.

To avoid such errors you have to use HTML/XML character encoding for JSON formatting operators like <, >, &&, etc.

OperatorEncoded character
<&lt;
>&gt;
&&amp;

After HTML/XML character encoding, above view formatting JSON will be converted to this:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if([$PublishDate] &lt;= @now &amp;&amp; [$IsPublished] == false, 'sp-field-severity--severeWarning', '')"
}

Then you can use below PnP PowerShell script to apply JSON View formatting to your SharePoint online list:

# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Display name of SharePoint list
$listName = "Ganesh Sanap Blogs"

# Name of SharePoint list view
$viewName = "All Items"

# JSON to apply to view formatting
$jsonViewFormatting = @'
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if([$PublishDate] &lt;= @now &amp;&amp; [$IsPublished] == false, 'sp-field-severity--severeWarning', '')"
}
'@

# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive

# Apply JSON view formatting
Set-PnPView -List $listName -Identity $viewName -Values @{CustomFormatter = $jsonViewFormatting}

Where [$PublishDate] and [$IsPublished] are the internal names of your SharePoint columns.

Once you run above script successfully and navigate to SharePoint list view, you will see that new JSON view formatting is applied to your SharePoint online list view using PnP PowerShell:

SharePoint Online Modern experience Apply JSON View formatting using PnP PowerShell
SharePoint Online: Apply JSON View formatting using PnP PowerShell

Learn more

sharepoint-online-apply-json-view-formatting-using-pnp-powershell

ganeshsanapblogs

SharePoint Online Modern experience Apply JSON View formatting using PnP PowerShell

#CES2023 : SwitchBot dévoile le premier hub supportant Matter

ces 2023 SwitchBot Hub une 1Le nouveau Hub 2 de SwitchBot a été présenté au CES 2023. Avec son support Matter, les produits de l’écosystème SwitchBot pourront fonctionner avec Matter via le Hub 2, le premier à venir étant le SwitchBot Curtain. Switchbot est une société qui a été fondée en 2016. Elle se concentre sur le développement de produits […]

#CES2023: NEO dévoile des dispositifs intelligents avec la norme Matter 1.0 WIFI

Découvrez la gamme de dispositifs intelligents Matter de NEO.Le CES de Las Vegas est un événement technologique de premier plan qui attire des visiteurs du monde entier et offre aux entreprises une plateforme pour présenter leurs dernières innovations en matière de technologie de l’électronique grand public. NEO profite de cet événement pour annoncer une gamme de dispositifs intelligents avec la norme Matter 1.0 […]

Eve Systems annonce 3 produits certifiés Matter au #CES2023

Eve Matter DevicesEve Systems a été l’un des premiers fabricants d’accessoires pour la maison intelligente à mettre à jour certains de ses produits existants pour prendre en charge Matter, la plate-forme de maison intelligente qui permet aux appareils de fonctionner sur plusieurs plates-formes telles qu’Alexa, Google Home et Apple HomeKit. Maintenant, la société annonce de nouveaux appareils […]

#CES2023 : Samsung lance son nouveau hub SmartThings Station

Samsung SmartThings StationSamsung a dévoilé lors du CES un nouveau hub pour profiter de l’expérience de maison intelligente SmartThings : le SmartThings Station. La particularité est que ce hub domotique abordable et facile à utiliser est aussi un chargeur rapide sans fil. Alors que le marché de la maison intelligente continue de croître, les utilisateurs ont besoin […]

En marge du CES 2023, Jeedom Luna fonctionnera avec Matter!

Jeedom Luna sera compatible Matter.Durant la semaine du CES 2023, différentes entreprises profitent de l’événement pour annoncer des nouveautés et cette année semble être celle de la norme Matter. Même si l’équipe de Jeedom n’est pas présente physiquement au CES, à cette occasion, l’entreprise dévoile plus d’informations sur la compatibilité de la nouvelle box Jeedom Luna avec la norme […]
❌
❌