Vue normale

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

How to find the Internal name of columns in SharePoint Online?

The internal name of a SharePoint column is a unique name that is automatically generated by SharePoint when a column is created. It is used by SharePoint internally to reference and retrieve the value of a particular column associated with an item or document. The internal name is generated based on the display name you provide but all special characters and spaces will be replaced with Unicode’s by SharePoint. Internal name is generated only once while creating a new column and it cannot be changed even if you change the display name of SharePoint column.

The internal name is not visible to users in the SharePoint user interface by default, but it is commonly used in various scenarios, such as in SharePoint REST APIs, Power Automate flow expressions, Power Apps formulas, PowerShell, etc. to interact with column data programmatically.

Where are Internal names of SharePoint columns used?

  1. Custom Scripts: When creating custom scripts, such as JavaScript or PowerShell, the internal names of columns are required to reference and manipulate the values of the columns while interacting with SharePoint data.
  2. Workflows: In SharePoint Designer workflows or Microsoft Power Automate (formerly known as Microsoft Flow), the internal names of columns are used to reference the values of the columns as inputs or outputs in the workflow actions and in expressions.
  3. Custom Solutions: When building custom solutions, such as SharePoint apps, SharePoint framework (SPFx) web parts, or custom code, the internal names of columns are required to interact with the columns programmatically.
  4. Power Apps: Few of the Power Apps functions like ShowColumns, SortByColumns, etc. requires using internal names of SharePoint columns in formula.
  5. JSON Formatting: Internal name of SharePoint column is required in JSON formatting to reference the column value with [$InternalNameOfColumn] syntax.

How to find the Internal name of a SharePoint column?

Using Modern experience list view

You can use sorting or filtering options from SharePoint online modern experience list view to find the internal name of a SharePoint column. Sort by and Filter by options are supported by most of the column types in SharePoint like Single line of text, Choice, Number, Date and Time, Yes/No (Boolean), Person or Group (single selection), etc.

For this afticle, we will use sorting based on SharePoint choice column as an example:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on column name/header from the list view and select either Ascending (A to Z) or Descending (Z to A) option from the popup menu:

Find internal name of SharePoint column by sorting choice column from SharePoint online modern experience list view
Find internal name of SharePoint column by sorting choice column

3. SharePoint will sort the list view based on selection and the browser URL will be changed like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?sortField=ChoiceColumn&isAscending=false

Where column name (ChoiceColumn) after sortField= is the internal name of your SharePoint choice column.

4. Similarly, when you use Filter by option in SharePoint modern experience to filter the list view based on Date and Time column (named as Start Date), SharePoint changes browser URL like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?FilterField1=Start_x0020_Date&FilterValue1=2023-04-05&FilterType1=DateTime

Where column name (Start_x0020_Date) after FilterField1= is the internal name of your SharePoint date and time column. Notice _x0020_ in internal column name which is an Unicode encoding of the space character in the display name of date and time column (Start Date).

Using Classic experience List settings page

Few of the SharePoint column types like Multiple lines of text, Hyperlink or Picture, Image, etc. does not support sorting or filtering from SharePoint modern experience list views. So, you have to use the classic experience list settings page to find the internal name for such SharePoint columns.

Follow below steps to find the internal name of multiple lines of text column using SharePoint classic experience list settings page:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on Settings (gear) icon from the top right corner and select List settings:

Open SharePoint online List settings page from modern experience list view to find the internal name of SharePoint column
Open SharePoint online list settings page

3. From list settings page, scroll down to the Columns section and click on the column name for which you want to find the internal name:

Open SharePoint online column settings page from classic experience list settings page to find the internal name of SharePoint column
Open SharePoint online Column settings page

4. SharePoint will open column settings page for the respective column with browser URL like:

https://contoso.sharepoint.com/sites/wlive/_layouts/15/FldEdit.aspx?List=%7B6FBA7FAE-AFC0-45D6-99EE-0AB20629EE41%7D&Field=MultilineTextCol
SharePoint online column settings page showing internal name of column
SharePoint online column settings page showing internal name of column

Where column name (MultilineTextCol) after Field= is the internal name of your SharePoint online multiple lines of text column.

Note: You can use this classic experience method to find out the internal name of SharePoint columns for all column types.

Using SharePoint REST API

You can use SharePoint REST API endpoint like below to get the internal name of SharePoint column based on it’s display name. Open URL in below format directly from browser tab:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/lists/getbytitle('InternalNames')/fields?$select=Title,InternalName&$filter=Title eq 'Multiline Text Column'
Find internal name of SharePoint online list column using SharePoint REST API
Find internal name of SharePoint column using SharePoint REST API
Using PnP PowerShell

You can use below PnP PowerShell script to find the internal name of SharePoint online list column using PnP PowerShell:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive
 
# Get internal name of SharePoint list column
Get-PnPField -Identity $columnName -List $listName | Select Title,InternalName
Find internal name of SharePoint online list column using PnP PowerShell
Find internal name of SharePoint column using PnP PowerShell
Using CLI for Microsoft 365

You can use below CLI for Microsoft 365 script to find the internal name of SharePoint online list column using CLI for Microsoft 365:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
	m365 login
}

# Get internal name of SharePoint list column
m365 spo field get --webUrl $siteUrl --listTitle $listName --title $columnName --output text
Find internal name of SharePoint online list column using CLI for Microsoft 365
Find internal name of SharePoint column using CLI for Microsoft 365

Best practices for naming SharePoint columns

When creating columns in SharePoint, it’s important to follow best practices for column naming to avoid using special characters or Unicode characters in internal names. Here are some recommended best practices:

  1. Use only alphanumeric characters: Stick to using letters (A-Z, a-z) and numbers (0-9) in column names. Avoid using special characters such as @, #, $, %, _, etc. Avoid column names beginning with numbers.
  2. Avoid spaces: Use PascalCase to separate words in column names instead of spaces. For example, use ColumnName instead of Column Name. This can help prevent issues with URLs, Unicode encoding, and referencing column names in scripts or code.
  3. Avoid reserved words: SharePoint has reserved words that are used for system functionality, and using them in column names may cause conflicts. Examples of reserved words include “ID”, “Modified”, “Created”, “Title”, etc. Avoid using these reserved words as column names.
  4. Keep it concise and meaningful: Use descriptive and meaningful names for columns that clearly indicate their purpose. Avoid using vague or generic names that may be confusing or ambiguous to users. Use column description to provide more information about the columns.
  5. Be consistent: Establish a consistent naming convention for columns across your SharePoint site or site collection to ensure uniformity and ease of management. This can also help with documentation, training, and maintenance of your SharePoint environment.

I hope you liked this article. Give your valuable feedback & suggestions in the comments section below and share this article with others.

Learn more

Working with SharePoint Online/Microsoft List Comments using JSON Formatting

In my previous blog about Commenting in SharePoint Online and Microsoft lists, I explained where you can find the comments options, what are the permission considerations, working with commenting using SharePoint REST APIs, etc. In this blog I will explain how to use SharePoint Online/Microsoft List Comments in JSON formatting.

Currently it is not possible to get the actual list item comments using JSON formatting. But, you can get the count of comments added to list item using [$_CommentCount].

Follow below steps to show Comments Count in list view:

1. Go to SharePoint Online/Microsoft list, click on Add column and select Single line of text.

Add an image column in SharePoint online list
Add a column in list

2. Complete Create a column fly out on the right by entering a Name for column and Description if required. Once complete click on Save.

Create a image column in SharePoint online list
Create a column in list

3. Click on the Comments Count column, select Column settings and then select Format this column.

JSON Column formatting in SharePoint Online list
Format the comments count column

4. Select Advanced mode at the bottom of the Format Comments Count column fly out, delete everything from the textbox, add the following JSON and click Save.

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "attributes": {
        "class": "ms-fontColor-themePrimary"
    },
    "style": {
        "font-size": "16px",
        "padding-left": "40px"
    },
    "children": [
        {
            "elmType": "span",
            "style": {
                "margin-top": "5px",
                "margin-right": "10px"
            },
            "attributes": {
                "iconName": "Comment"
            }
        },
        {
            "elmType": "span",
            "txtContent": "=if([$_CommentCount] == '' , 0 , [$_CommentCount])"
        }
    ]
}

Where [$_CommentCount] is an internal name of hidden Comment Count column SharePoint list.

JSON Column formatting in SharePoint Online list- Advanced mode
Format the comments count column – Advanced mode

5. Close the Format Comments Count column fly out and you will see below output in list view:

Showing Comments Count in SharePoint Online using JSON Column Formatting
Comments Count using JSON Formatting

Next Step: This example is just to show the comments count in list view. So, you would want to hide this column from list form. Check this documentation to hide Comments Count column from list form.

Learn More

SharePoint JSON Formatting: Remove column name from group header

SharePoint’s JSON formatting capabilities empower users to customize the look and feel of SharePoint lists and libraries effortlessly. One common customization request is to remove the column name from the group header in a grouped SharePoint list view. In this blog post, we’ll explore why you might want to remove the column name and provide a step-by-step guide on achieving this using SharePoint JSON formatting.

Why Remove the Column Name?

When organizing data in SharePoint lists, you may find that the default group headers display the column names. While this is useful in many scenarios, there are times when you might prefer a cleaner, more streamlined view. Removing the column name from the grouped header can help reduce visual clutter and focus on the column value for each group.

How to Remove Column Name from Group Header?

Follow below steps to remove the column name from group header in SharePoint online or Microsoft Lists’ list view:

1. First, navigate to the SharePoint list for which you want to apply the JSON formatting. Click on the “Switch view options” drop down from top right corner of the list and select the view where you want to remove the column name from the group header.

2. Once in the desired list view, click on the “Switch view options” drop down again and select the “Format current view” option, which opens the list formatting pane.

3. Within the list formatting pane, locate the “Advanced mode” option and click on it to access the JSON formatting editor. Here you can modify the JSON to achieve the desired customization.

4. To remove the column name from the group header, copy below JSON and paste it in the JSON formatting editor:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"groupProps": {
"headerFormatter": {
"elmType": "div",
"style": {
"padding-left": "12px",
"font-size": "16px",
"font-weight": "400",
"cursor": "pointer",
"outline": "0px",
"white-space": "nowrap",
"text-overflow": "ellipsis"
},
"customRowAction": {
"action": "defaultClick"
},
"children": [
{
"elmType": "div",
"children": [
{
"elmType": "span",
"style": {
"padding": "5px 5px 5px 5px"
},
"txtContent": "@group.fieldData.displayValue"
}
]
},
{
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"flex-direction": "row",
"justify-content": "center"
},
"children": [
{
"elmType": "div",
"txtContent": "=' (' + @group.count + ')'"
}
]
}
]
}
]
}
}
}

5. Click on the “Save” button within the JSON list formatting pane to apply the changes.

Once saved, the SharePoint list view will reflect the updated formatting, with the column name effectively removed from the group header.

Note

If you have applied the “Group by” on Person or Group (people field) OR Lookup column, [object object] will appear in the group header after applying above JSON. In that case, you will have to modify above JSON slightly as per the following table:

Type of grouped columnPart of the JSON to be changedChange to
Person or Group@group.fieldData.displayValue@group.fieldData.title
Lookup@group.fieldData.displayValue@group.fieldData.lookupValue

Also, if you have grouped your SharePoint list view based on two columns (for example: person or group and single line of text column), you can change the text to show (txtContent) based on display name of column like:

"txtContent": "=if(@group.columnDisplayName == 'Assigned To', @group.fieldData.title, @group.fieldData.displayValue)"

By following these steps, you can harness the power of SharePoint’s JSON formatting capabilities to achieve a cleaner and more tailored presentation of your grouped list view data.

I hope this guide has been helpful in demonstrating how to remove the column name from the group header in a SharePoint list view using JSON formatting.

Above JSON is also available on GitHub in PnP List Formatting Repository at: Remove column name from group header

Learn more

SharePoint Online: All you need to know about Commenting in Lists

Microsoft recently introduced a new feature of commenting in SharePoint Online lists and Microsoft lists. Using this feature users will be able to add and delete comments on list items. Users can view all comments on a list item and filter between views that show comments or activity related to an item in details pane.

Microsoft has started rolling out this feature to all SharePoint Online tenants in December 2020 release, see Roadmap.

Where can you find Comments options?

Comments options are currently located at below three places in SharePoint Online/Microsoft lists:

List view

Users can see which list items have comments when they access the SharePoint Online list view or Microsoft list home page. Comments option will be shown on command bar when you select a list item as well as at the right hand side of Title column. When you hover over on comments icon it will show you the count of comments added to the list item.

New Comments in SharePoint list view
Comments options in List view
Display/Edit form

By default, users will see a new comments pane alongside the list item form when they access a list. Users can toggle the comment pane visibility by clicking the comments icon. When you hide comments, the pane does not collapse. The comments pane will be closed by default for lists customized by Power Apps.

New Comments in SharePoint list display form
Comments options on Display form
Details Pane

Users can see the Comments and All activity related to list item on details pane. Users can filter views that show comments or activity by using the dropdown under “More details” section.

New Comments options in Details pane in SharePoint Online list
Comments options in Details pane

Permission Considerations

Comments follow the permission settings inherent in SharePoint Online and Microsoft Lists.

  • Users with read-only permission can only view comments.
  • Those with list edit permission can make comments as well as delete comments; editing comments is currently not possible. 

Where the Comments will be stored?

Comments are stored in the schema for each list, which is based on the SharePoint storage platform.

Working with SharePoint REST APIs

As comments are stored within the list schema itself and not with list items, it is not possible to fetch comments using  $select with /items endpoint. However, you can get the list item comments using below endpoint:

https://<tenant>.sharepoint.com/sites/<site>/_api/web/lists/getbytitle('<list-name>')/GetItemById(<item-id>)/Comments()

//OR

https://<tenant>.sharepoint.com/sites/<site>/_api/web/lists/getbytitle('<list-name>')/items(<item-id>)/Comments()

For more information on working with comments using SharePoint REST APIs, check:

Working with JSON Formatting

Currently it is not possible to get the actual list item comments value using JSON formatting. But, you can get the count of comments added to list item using [$_CommentCount] which is an internal name of SharePoint list column that returns the count of list item comments.

Check how you can get comments count and show it in SharePoint list view at: Working with SharePoint Online/Microsoft List Comments using JSON Formatting.

Current Limitations

  • Editing comments is currently not possible.
  • Any user can delete the list item comments. Currently there is no way to disable deletion of comments.
  • Maximum characters limit in list comments: 2000 characters
  • Classic lists that are not yet built to show up in modern user interfaces, like Task lists, will not have this commenting feature.
  • Commenting on lists in Teams is not available with this release.
  • Comments are not indexed by Search.

Enable/Disable Comments

Currently it is not possible to disable commenting at the site or list level. Microsoft is working on the new feature which will allow users to enable/disable the comments for individual SharePoint lists. However, Admins can enable/disable this feature at the organization level by changing the CommentsOnListItemsDisabled parameter in the Set-SPOTenant PowerShell cmdlet:

Read more about how to enable/disable the commenting in SharePoint Online/Microsoft Lists at: How to Enable/Disable the commenting in SharePoint Online/Microsoft Lists.

What’s Next?

  • Currently it is not possible to disable commenting at the site or list level. Microsoft is currently working on this feature update, more information at: Enable/Disable the comments for a SharePoint Online/Microsoft List.
  • @mentions in comments:
    • Get a colleague’s attention to an item in a list by @mentioning them within list comments. That person will receive a notification and a link that takes them directly back to the item, to review the comment and take the requested action.

I hope you liked this blog. Give your valuable feedback & suggestions in the comments section below and share this blog with others.

SharePoint Online: Display Country Flags using JSON Formatting – multiple selections

SharePoint Online JSON formatting is a powerful tool that allows users to customize the display of list data, bringing a new level of functionality and aesthetics to SharePoint online lists. In my previous blog post, we saw how to show country flags using SharePoint JSON formatting for single selection choice column.

The JSON formatting sample given in this blog post demonstrates displaying flags of the counties selected in the multiple selection SharePoint choice column.

The country flags are shown using the FlagCDN – CDN & API of flags web site API. As Microsoft have blocked the external domain images in SharePoint JSON formatting by default, you will have to allow the flagcdn.com domain in HTML Field Security settings of your SharePoint site by following this step by step guide: Why external domain image URLs are not working in SharePoint Online JSON Formatting?

Also, You can find the list of countries used in this JSON sample at: List of Countries.

Multiple selection choice column settings

Add list of countries in the choice column settings like:

Multiple selection SharePoint choice column settings

SharePoint Online JSON sample

Use below JSON to apply JSON column formatting for multiple selection SharePoint choice column to show the flag of selected countries:

{
	"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
	"elmType": "div",
	"inlineEditField": "[$Countries]",
	"children": [
		{
			"elmType": "div",
			"style": {
				"display": "flex",
				"flex-direction": "column",
				"justify-content": "flex-start",
				"flex-wrap": "wrap",
				"margin": "5px 0px"
			},
			"children": [
				{
					"elmType": "div",
					"forEach": "choiceIterator in @currentField",
					"style": {
						"margin": "3px 0px",
						"display": "flex",
						"flex-direction": "row",
						"align-items": "center"
					},
					"children": [
						{
							"elmType": "img",
							"attributes": {
								"src": "=if([$choiceIterator],'https://flagcdn.com/w550/' + if([$choiceIterator]=='Afghanistan','af',if([$choiceIterator]=='Albania','al',if([$choiceIterator]=='Algeria','dz',if([$choiceIterator]=='American Samoa','as',if([$choiceIterator]=='Andorra','ad',if([$choiceIterator]=='Angola','ao',if([$choiceIterator]=='Anguilla','ai',if([$choiceIterator]=='Antarctica','aq',if([$choiceIterator]=='Antigua and Barbuda','ag',if([$choiceIterator]=='Argentina','ar',if([$choiceIterator]=='Armenia','am',if([$choiceIterator]=='Aruba','aw',if([$choiceIterator]=='Australia','au',if([$choiceIterator]=='Austria','at',if([$choiceIterator]=='Azerbaijan','az',if([$choiceIterator]=='Bahamas','bs',if([$choiceIterator]=='Bahrain','bh',if([$choiceIterator]=='Bangladesh','bd',if([$choiceIterator]=='Barbados','bb',if([$choiceIterator]=='Belarus','by',if([$choiceIterator]=='Belgium','be',if([$choiceIterator]=='Belize','bz',if([$choiceIterator]=='Benin','bj',if([$choiceIterator]=='Bermuda','bm',if([$choiceIterator]=='Bhutan','bt',if([$choiceIterator]=='Bolivia','bo',if([$choiceIterator]=='Bonaire','bq',if([$choiceIterator]=='Bosnia and Herzegovina','ba',if([$choiceIterator]=='Botswana','bw',if([$choiceIterator]=='Bouvet Island','bv',if([$choiceIterator]=='Brazil','br',if([$choiceIterator]=='British Indian Ocean Territory','io',if([$choiceIterator]=='Brunei','bn',if([$choiceIterator]=='Bulgaria','bg',if([$choiceIterator]=='Burkina Faso','bf',if([$choiceIterator]=='Burundi','bi',if([$choiceIterator]=='Cambodia','kh',if([$choiceIterator]=='Cameroon','cm',if([$choiceIterator]=='Canada','ca',if([$choiceIterator]=='Cape Verde','cv',if([$choiceIterator]=='Cayman Islands','ky',if([$choiceIterator]=='Central African Republic','cf',if([$choiceIterator]=='Chad','td',if([$choiceIterator]=='Chile','cl',if([$choiceIterator]=='China','cn',if([$choiceIterator]=='Christmas Island','cx',if([$choiceIterator]=='Cocos (Keeling) Islands','cc',if([$choiceIterator]=='Colombia','co',if([$choiceIterator]=='Comoros','km',if([$choiceIterator]=='Democratic Republic of the Congo','cd',if([$choiceIterator]=='Cook Islands','ck',if([$choiceIterator]=='Costa Rica','cr',if([$choiceIterator]=='Croatia','hr',if([$choiceIterator]=='Cuba','cu',if([$choiceIterator]=='Cyprus','cy',if([$choiceIterator]=='Czech Republic','cz',if([$choiceIterator]=='Denmark','dk',if([$choiceIterator]=='Djibouti','dj',if([$choiceIterator]=='Dominica','dm',if([$choiceIterator]=='Dominican Republic','do',if([$choiceIterator]=='Ecuador','ec',if([$choiceIterator]=='Egypt','eg',if([$choiceIterator]=='El Salvador','sv',if([$choiceIterator]=='Equatorial Guinea','gq',if([$choiceIterator]=='Eritrea','er',if([$choiceIterator]=='Estonia','ee',if([$choiceIterator]=='Ethiopia','et',if([$choiceIterator]=='Falkland Islands (Malvinas)','fk',if([$choiceIterator]=='Faroe Islands','fo',if([$choiceIterator]=='Fiji','fj',if([$choiceIterator]=='Finland','fi',if([$choiceIterator]=='France','fr',if([$choiceIterator]=='French Guiana','gf',if([$choiceIterator]=='French Polynesia','pf',if([$choiceIterator]=='French Southern Territories','tf',if([$choiceIterator]=='Gabon','ga',if([$choiceIterator]=='Gambia','gm',if([$choiceIterator]=='Georgia','ge',if([$choiceIterator]=='Germany','de',if([$choiceIterator]=='Ghana','gh',if([$choiceIterator]=='Gibraltar','gi',if([$choiceIterator]=='Greece','gr',if([$choiceIterator]=='Greenland','gl',if([$choiceIterator]=='Grenada','gd',if([$choiceIterator]=='Guadeloupe','gp',if([$choiceIterator]=='Guam','gu',if([$choiceIterator]=='Guatemala','gt',if([$choiceIterator]=='Guernsey','gg',if([$choiceIterator]=='Guinea','gn',if([$choiceIterator]=='Guinea-Bissau','gw',if([$choiceIterator]=='Guyana','gy',if([$choiceIterator]=='Haiti','ht',if([$choiceIterator]=='Heard Island and McDonald Islands','hm',if([$choiceIterator]=='Honduras','hn',if([$choiceIterator]=='Hong Kong','hk',if([$choiceIterator]=='Hungary','hu',if([$choiceIterator]=='Iceland','is',if([$choiceIterator]=='India','in',if([$choiceIterator]=='Indonesia','id',if([$choiceIterator]=='Iran','ir',if([$choiceIterator]=='Iraq','iq',if([$choiceIterator]=='Ireland','ie',if([$choiceIterator]=='Isle of Man','im',if([$choiceIterator]=='Israel','il',if([$choiceIterator]=='Italy','it',if([$choiceIterator]=='Jamaica','jm',if([$choiceIterator]=='Japan','jp',if([$choiceIterator]=='Jersey','je',if([$choiceIterator]=='Jordan','jo',if([$choiceIterator]=='Kazakhstan','kz',if([$choiceIterator]=='Kenya','ke',if([$choiceIterator]=='Kiribati','ki',if([$choiceIterator]=='North Korea','kp',if([$choiceIterator]=='South Korea','kr',if([$choiceIterator]=='Kuwait','kw',if([$choiceIterator]=='Kyrgyzstan','kg',if([$choiceIterator]=='Laos','la',if([$choiceIterator]=='Latvia','lv',if([$choiceIterator]=='Lebanon','lb',if([$choiceIterator]=='Lesotho','ls',if([$choiceIterator]=='Liberia','lr',if([$choiceIterator]=='Libya','ly',if([$choiceIterator]=='Liechtenstein','li',if([$choiceIterator]=='Lithuania','lt',if([$choiceIterator]=='Luxembourg','lu',if([$choiceIterator]=='Macao','mo',if([$choiceIterator]=='North Macedonia','mk',if([$choiceIterator]=='Madagascar','mg',if([$choiceIterator]=='Malawi','mw',if([$choiceIterator]=='Malaysia','my',if([$choiceIterator]=='Maldives','mv',if([$choiceIterator]=='Mali','ml',if([$choiceIterator]=='Malta','mt',if([$choiceIterator]=='Marshall Islands','mh',if([$choiceIterator]=='Martinique','mq',if([$choiceIterator]=='Mauritania','mr',if([$choiceIterator]=='Mauritius','mu',if([$choiceIterator]=='Mayotte','yt',if([$choiceIterator]=='Mexico','mx',if([$choiceIterator]=='Micronesia','fm',if([$choiceIterator]=='Moldova','md',if([$choiceIterator]=='Monaco','mc',if([$choiceIterator]=='Mongolia','mn',if([$choiceIterator]=='Montenegro','me',if([$choiceIterator]=='Montserrat','ms',if([$choiceIterator]=='Morocco','ma',if([$choiceIterator]=='Mozambique','mz',if([$choiceIterator]=='Myanmar','mm',if([$choiceIterator]=='Namibia','na',if([$choiceIterator]=='Nauru','nr',if([$choiceIterator]=='Nepal','np',if([$choiceIterator]=='Netherlands','nl',if([$choiceIterator]=='New Caledonia','nc',if([$choiceIterator]=='New Zealand','nz',if([$choiceIterator]=='Nicaragua','ni',if([$choiceIterator]=='Niger','ne',if([$choiceIterator]=='Nigeria','ng',if([$choiceIterator]=='Niue','nu',if([$choiceIterator]=='Norfolk Island','nf',if([$choiceIterator]=='Northern Mariana Islands','mp',if([$choiceIterator]=='Norway','no',if([$choiceIterator]=='Oman','om',if([$choiceIterator]=='Pakistan','pk',if([$choiceIterator]=='Palau','pw',if([$choiceIterator]=='Palestine','ps',if([$choiceIterator]=='Panama','pa',if([$choiceIterator]=='Papua New Guinea','pg',if([$choiceIterator]=='Paraguay','py',if([$choiceIterator]=='Peru','pe',if([$choiceIterator]=='Philippines','ph',if([$choiceIterator]=='Pitcairn','pn',if([$choiceIterator]=='Poland','pl',if([$choiceIterator]=='Portugal','pt',if([$choiceIterator]=='Puerto Rico','pr',if([$choiceIterator]=='Qatar','qa',if([$choiceIterator]=='Romania','ro',if([$choiceIterator]=='Russia','ru',if([$choiceIterator]=='Rwanda','rw',if([$choiceIterator]=='Saint Barthélemy','bl',if([$choiceIterator]=='Saint Helena, Ascension and Tristan da Cunha','sh',if([$choiceIterator]=='Saint Kitts and Nevis','kn',if([$choiceIterator]=='Saint Lucia','lc',if([$choiceIterator]=='Saint Martin','mf',if([$choiceIterator]=='Saint Pierre and Miquelon','pm',if([$choiceIterator]=='Saint Vincent and the Grenadines','vc',if([$choiceIterator]=='Samoa','ws',if([$choiceIterator]=='San Marino','sm',if([$choiceIterator]=='Sao Tome and Principe','st',if([$choiceIterator]=='Saudi Arabia','sa',if([$choiceIterator]=='Senegal','sn',if([$choiceIterator]=='Serbia','rs',if([$choiceIterator]=='Seychelles','sc',if([$choiceIterator]=='Sierra Leone','sl',if([$choiceIterator]=='Singapore','sg',if([$choiceIterator]=='Sint Maarten','sx',if([$choiceIterator]=='Slovakia','sk',if([$choiceIterator]=='Slovenia','si',if([$choiceIterator]=='Solomon Islands','sb',if([$choiceIterator]=='Somalia','so',if([$choiceIterator]=='South Africa','za',if([$choiceIterator]=='South Georgia and the South Sandwich Islands','gs',if([$choiceIterator]=='South Sudan','ss',if([$choiceIterator]=='Spain','es',if([$choiceIterator]=='Sri Lanka','lk',if([$choiceIterator]=='Sudan','sd',if([$choiceIterator]=='Suriname','sr',if([$choiceIterator]=='Svalbard and Jan Mayen','sj',if([$choiceIterator]=='Swaziland','sz',if([$choiceIterator]=='Sweden','se',if([$choiceIterator]=='Switzerland','ch',if([$choiceIterator]=='Syria','sy',if([$choiceIterator]=='Taiwan','tw',if([$choiceIterator]=='Tajikistan','tj',if([$choiceIterator]=='Tanzania','tz',if([$choiceIterator]=='Thailand','th',if([$choiceIterator]=='Timor-Leste','tl',if([$choiceIterator]=='Togo','tg',if([$choiceIterator]=='Tokelau','tk',if([$choiceIterator]=='Tonga','to',if([$choiceIterator]=='Trinidad and Tobago','tt',if([$choiceIterator]=='Tunisia','tn',if([$choiceIterator]=='Turkey','tr',if([$choiceIterator]=='Turkmenistan','tm',if([$choiceIterator]=='Turks and Caicos Islands','tc',if([$choiceIterator]=='Tuvalu','tv',if([$choiceIterator]=='Uganda','ug',if([$choiceIterator]=='Ukraine','ua',if([$choiceIterator]=='United Arab Emirates','ae',if([$choiceIterator]=='United Kingdom','gb',if([$choiceIterator]=='United States','us',if([$choiceIterator]=='United States Minor Outlying Islands','um',if([$choiceIterator]=='Uruguay','uy',if([$choiceIterator]=='Uzbekistan','uz',if([$choiceIterator]=='Vanuatu','vu',if([$choiceIterator]=='Vatican City','va',if([$choiceIterator]=='Venezuela','ve',if([$choiceIterator]=='Viet Nam','vn',if([$choiceIterator]=='British Virgin Islands','vg',if([$choiceIterator]=='United States Virgin Islands','vi',if([$choiceIterator]=='Wallis and Futuna','wf',if([$choiceIterator]=='Western Sahara','eh',if([$choiceIterator]=='Yemen','ye',if([$choiceIterator]=='Zambia','zm',if([$choiceIterator]=='Zimbabwe','zw','')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + '.png','')",
								"title": ""
							},
							"style": {
								"max-width": "50px",
								"padding": "0 10px 0 0"
							}
						},
						{
							"elmType": "span",
							"txtContent": "[$choiceIterator]"
						}
					]
				}
			]
		}
	]
}

Where [$Countries] is the internal name of SharePoint choice column. You can get the internal name of your SharePoint list column by following this article: How to find the Internal name of columns in SharePoint Online?

Output

Multiple selection SharePoint choice column showing country flags using SharePoint online JSON formatting
Displaying country flags using SharePoint JSON formatting

Learn more

SharePoint Online: Display Country Flags using JSON Formatting

SharePoint Online JSON formatting is a powerful tool that allows users to customize the display of list data, bringing a new level of functionality and aesthetics to SharePoint online lists. In this blog post, we’ll explore an exciting and educational application of JSON formatting for displaying country flags within SharePoint lists.

The JSON formatting sample given in this blog post demonstrates displaying flags of the counties selected in the single selection SharePoint choice column.

The country flags are shown using the FlagCDN – CDN & API of flags web site API. As Microsoft have blocked the external domain images in SharePoint JSON formatting by default, you will have to allow the flagcdn.com domain in HTML Field Security settings of your SharePoint site by following this step by step guide: Why external domain image URLs are not working in SharePoint Online JSON Formatting?

Also, You can find the list of countries used in this JSON sample at: List of Countries.

Single selection choice column settings

Add list of countries in the choice column settings like:

Single selection SharePoint choice column settings to display country flags using SharePoint online JSON formatting
Single selection SharePoint choice column settings

SharePoint Online JSON sample

Use below JSON to apply JSON column formatting for single selection SharePoint choice column to show the flag of selected country:

{
	"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
	"elmType": "div",
	"inlineEditField": "[$Country]",
	"children": [
		{
			"elmType": "img",
			"attributes": {
				"src": "=if(@currentField,'https://flagcdn.com/w550/' + if(@currentField=='Afghanistan','af',if(@currentField=='Albania','al',if(@currentField=='Algeria','dz',if(@currentField=='American Samoa','as',if(@currentField=='Andorra','ad',if(@currentField=='Angola','ao',if(@currentField=='Anguilla','ai',if(@currentField=='Antarctica','aq',if(@currentField=='Antigua and Barbuda','ag',if(@currentField=='Argentina','ar',if(@currentField=='Armenia','am',if(@currentField=='Aruba','aw',if(@currentField=='Australia','au',if(@currentField=='Austria','at',if(@currentField=='Azerbaijan','az',if(@currentField=='Bahamas','bs',if(@currentField=='Bahrain','bh',if(@currentField=='Bangladesh','bd',if(@currentField=='Barbados','bb',if(@currentField=='Belarus','by',if(@currentField=='Belgium','be',if(@currentField=='Belize','bz',if(@currentField=='Benin','bj',if(@currentField=='Bermuda','bm',if(@currentField=='Bhutan','bt',if(@currentField=='Bolivia','bo',if(@currentField=='Bonaire','bq',if(@currentField=='Bosnia and Herzegovina','ba',if(@currentField=='Botswana','bw',if(@currentField=='Bouvet Island','bv',if(@currentField=='Brazil','br',if(@currentField=='British Indian Ocean Territory','io',if(@currentField=='Brunei','bn',if(@currentField=='Bulgaria','bg',if(@currentField=='Burkina Faso','bf',if(@currentField=='Burundi','bi',if(@currentField=='Cambodia','kh',if(@currentField=='Cameroon','cm',if(@currentField=='Canada','ca',if(@currentField=='Cape Verde','cv',if(@currentField=='Cayman Islands','ky',if(@currentField=='Central African Republic','cf',if(@currentField=='Chad','td',if(@currentField=='Chile','cl',if(@currentField=='China','cn',if(@currentField=='Christmas Island','cx',if(@currentField=='Cocos (Keeling) Islands','cc',if(@currentField=='Colombia','co',if(@currentField=='Comoros','km',if(@currentField=='Democratic Republic of the Congo','cd',if(@currentField=='Cook Islands','ck',if(@currentField=='Costa Rica','cr',if(@currentField=='Croatia','hr',if(@currentField=='Cuba','cu',if(@currentField=='Cyprus','cy',if(@currentField=='Czech Republic','cz',if(@currentField=='Denmark','dk',if(@currentField=='Djibouti','dj',if(@currentField=='Dominica','dm',if(@currentField=='Dominican Republic','do',if(@currentField=='Ecuador','ec',if(@currentField=='Egypt','eg',if(@currentField=='El Salvador','sv',if(@currentField=='Equatorial Guinea','gq',if(@currentField=='Eritrea','er',if(@currentField=='Estonia','ee',if(@currentField=='Ethiopia','et',if(@currentField=='Falkland Islands (Malvinas)','fk',if(@currentField=='Faroe Islands','fo',if(@currentField=='Fiji','fj',if(@currentField=='Finland','fi',if(@currentField=='France','fr',if(@currentField=='French Guiana','gf',if(@currentField=='French Polynesia','pf',if(@currentField=='French Southern Territories','tf',if(@currentField=='Gabon','ga',if(@currentField=='Gambia','gm',if(@currentField=='Georgia','ge',if(@currentField=='Germany','de',if(@currentField=='Ghana','gh',if(@currentField=='Gibraltar','gi',if(@currentField=='Greece','gr',if(@currentField=='Greenland','gl',if(@currentField=='Grenada','gd',if(@currentField=='Guadeloupe','gp',if(@currentField=='Guam','gu',if(@currentField=='Guatemala','gt',if(@currentField=='Guernsey','gg',if(@currentField=='Guinea','gn',if(@currentField=='Guinea-Bissau','gw',if(@currentField=='Guyana','gy',if(@currentField=='Haiti','ht',if(@currentField=='Heard Island and McDonald Islands','hm',if(@currentField=='Honduras','hn',if(@currentField=='Hong Kong','hk',if(@currentField=='Hungary','hu',if(@currentField=='Iceland','is',if(@currentField=='India','in',if(@currentField=='Indonesia','id',if(@currentField=='Iran','ir',if(@currentField=='Iraq','iq',if(@currentField=='Ireland','ie',if(@currentField=='Isle of Man','im',if(@currentField=='Israel','il',if(@currentField=='Italy','it',if(@currentField=='Jamaica','jm',if(@currentField=='Japan','jp',if(@currentField=='Jersey','je',if(@currentField=='Jordan','jo',if(@currentField=='Kazakhstan','kz',if(@currentField=='Kenya','ke',if(@currentField=='Kiribati','ki',if(@currentField=='North Korea','kp',if(@currentField=='South Korea','kr',if(@currentField=='Kuwait','kw',if(@currentField=='Kyrgyzstan','kg',if(@currentField=='Laos','la',if(@currentField=='Latvia','lv',if(@currentField=='Lebanon','lb',if(@currentField=='Lesotho','ls',if(@currentField=='Liberia','lr',if(@currentField=='Libya','ly',if(@currentField=='Liechtenstein','li',if(@currentField=='Lithuania','lt',if(@currentField=='Luxembourg','lu',if(@currentField=='Macao','mo',if(@currentField=='North Macedonia','mk',if(@currentField=='Madagascar','mg',if(@currentField=='Malawi','mw',if(@currentField=='Malaysia','my',if(@currentField=='Maldives','mv',if(@currentField=='Mali','ml',if(@currentField=='Malta','mt',if(@currentField=='Marshall Islands','mh',if(@currentField=='Martinique','mq',if(@currentField=='Mauritania','mr',if(@currentField=='Mauritius','mu',if(@currentField=='Mayotte','yt',if(@currentField=='Mexico','mx',if(@currentField=='Micronesia','fm',if(@currentField=='Moldova','md',if(@currentField=='Monaco','mc',if(@currentField=='Mongolia','mn',if(@currentField=='Montenegro','me',if(@currentField=='Montserrat','ms',if(@currentField=='Morocco','ma',if(@currentField=='Mozambique','mz',if(@currentField=='Myanmar','mm',if(@currentField=='Namibia','na',if(@currentField=='Nauru','nr',if(@currentField=='Nepal','np',if(@currentField=='Netherlands','nl',if(@currentField=='New Caledonia','nc',if(@currentField=='New Zealand','nz',if(@currentField=='Nicaragua','ni',if(@currentField=='Niger','ne',if(@currentField=='Nigeria','ng',if(@currentField=='Niue','nu',if(@currentField=='Norfolk Island','nf',if(@currentField=='Northern Mariana Islands','mp',if(@currentField=='Norway','no',if(@currentField=='Oman','om',if(@currentField=='Pakistan','pk',if(@currentField=='Palau','pw',if(@currentField=='Palestine','ps',if(@currentField=='Panama','pa',if(@currentField=='Papua New Guinea','pg',if(@currentField=='Paraguay','py',if(@currentField=='Peru','pe',if(@currentField=='Philippines','ph',if(@currentField=='Pitcairn','pn',if(@currentField=='Poland','pl',if(@currentField=='Portugal','pt',if(@currentField=='Puerto Rico','pr',if(@currentField=='Qatar','qa',if(@currentField=='Romania','ro',if(@currentField=='Russia','ru',if(@currentField=='Rwanda','rw',if(@currentField=='Saint Barthélemy','bl',if(@currentField=='Saint Helena, Ascension and Tristan da Cunha','sh',if(@currentField=='Saint Kitts and Nevis','kn',if(@currentField=='Saint Lucia','lc',if(@currentField=='Saint Martin','mf',if(@currentField=='Saint Pierre and Miquelon','pm',if(@currentField=='Saint Vincent and the Grenadines','vc',if(@currentField=='Samoa','ws',if(@currentField=='San Marino','sm',if(@currentField=='Sao Tome and Principe','st',if(@currentField=='Saudi Arabia','sa',if(@currentField=='Senegal','sn',if(@currentField=='Serbia','rs',if(@currentField=='Seychelles','sc',if(@currentField=='Sierra Leone','sl',if(@currentField=='Singapore','sg',if(@currentField=='Sint Maarten','sx',if(@currentField=='Slovakia','sk',if(@currentField=='Slovenia','si',if(@currentField=='Solomon Islands','sb',if(@currentField=='Somalia','so',if(@currentField=='South Africa','za',if(@currentField=='South Georgia and the South Sandwich Islands','gs',if(@currentField=='South Sudan','ss',if(@currentField=='Spain','es',if(@currentField=='Sri Lanka','lk',if(@currentField=='Sudan','sd',if(@currentField=='Suriname','sr',if(@currentField=='Svalbard and Jan Mayen','sj',if(@currentField=='Swaziland','sz',if(@currentField=='Sweden','se',if(@currentField=='Switzerland','ch',if(@currentField=='Syria','sy',if(@currentField=='Taiwan','tw',if(@currentField=='Tajikistan','tj',if(@currentField=='Tanzania','tz',if(@currentField=='Thailand','th',if(@currentField=='Timor-Leste','tl',if(@currentField=='Togo','tg',if(@currentField=='Tokelau','tk',if(@currentField=='Tonga','to',if(@currentField=='Trinidad and Tobago','tt',if(@currentField=='Tunisia','tn',if(@currentField=='Turkey','tr',if(@currentField=='Turkmenistan','tm',if(@currentField=='Turks and Caicos Islands','tc',if(@currentField=='Tuvalu','tv',if(@currentField=='Uganda','ug',if(@currentField=='Ukraine','ua',if(@currentField=='United Arab Emirates','ae',if(@currentField=='United Kingdom','gb',if(@currentField=='United States','us',if(@currentField=='United States Minor Outlying Islands','um',if(@currentField=='Uruguay','uy',if(@currentField=='Uzbekistan','uz',if(@currentField=='Vanuatu','vu',if(@currentField=='Vatican City','va',if(@currentField=='Venezuela','ve',if(@currentField=='Viet Nam','vn',if(@currentField=='British Virgin Islands','vg',if(@currentField=='United States Virgin Islands','vi',if(@currentField=='Wallis and Futuna','wf',if(@currentField=='Western Sahara','eh',if(@currentField=='Yemen','ye',if(@currentField=='Zambia','zm',if(@currentField=='Zimbabwe','zw','')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + '.png','')",
				"title": ""
			},
			"style": {
				"max-width": "50px",
				"padding": "0 10px 0 0"
			}
		},
		{
			"elmType": "span",
			"txtContent": "@currentField"
		}
	]
}

Where [$Country] is the internal name of SharePoint choice column. You can get the internal name of your SharePoint list column by following this article: How to find the Internal name of columns in SharePoint Online?

Output

Single selection SharePoint choice column showing country flags using SharePoint online JSON formatting
Displaying country flags using SharePoint JSON formatting

Learn more

SharePoint Online: External Image URLs not working in JSON Formatting

SharePoint Online is a powerful collaboration and content management platform that empowers organizations to create, manage, and share information seamlessly. JSON formatting in SharePoint online allows users to customize the look and feel of the columns, views and forms in their SharePoint lists and libraries.

Earlier this year Microsoft updated the SharePoint JSON formatting feature and blocked most of the external domain image sources by default in custom JSON column and view formatting.

Only images from the following domains are allowed by default:

  • tenant domain, configured multi-geo domains and vanity domains (company.sharepoint.com)
  • cdn.office.net, akamaihd.net, static2.sharepointonline.com CDNs

The Solution – Modifying HTML Field Security Settings:

To address the challenge of displaying external web site domain images in JSON formatting, one effective solution is to adjust the HTML field security settings of your SharePoint site. This involves whitelisting trusted external domains or CDNs to allow their images to be displayed within your SharePoint environment. Follow these steps to implement the solution:

1. Go to your SharePoint online site.

2. Click on Settings (gear) icon from top right corner and select Site information.

3. Click on View all site settings link from Site information panel, it will open the SharePoint site settings page.

4. Under the Site Collection Administration section, locate and click on the HTML Field Security settings link.

5. Select Allow contributors to insert iframes only from the following domains, add external web site domain from where you are using the images under Allow iframes from this domain text box and click Add button.

6. Click OK button at the bottom of HTML Field Security settings page to save the changes.

Allow external site domain from SharePoint HTML Field Security settings

7. Navigate back to the SharePoint list where you are using external image with JSON formatting and refresh the web page. Now, you should see that the external images are working using the SharePoint Online JSON formatting.

Output

Before adding external site domain to SharePoint HTML Field Security Settings:

External Image URLs are not working in SharePoint Online JSON formatting
External Image URLs are not working in SharePoint Online JSON formatting

After adding external site domain to SharePoint HTML Field Security Settings:

External Image URLs are working in SharePoint Online JSON formatting after adding external web site domain to SharePoint HTML Field Security settings
Working External Image URLs in SharePoint Online JSON formatting

Learn more

How to find the Internal name of columns in SharePoint Online?

The internal name of a SharePoint column is a unique name that is automatically generated by SharePoint when a column is created. It is used by SharePoint internally to reference and retrieve the value of a particular column associated with an item or document. The internal name is generated based on the display name you provide but all special characters and spaces will be replaced with Unicode’s by SharePoint. Internal name is generated only once while creating a new column and it cannot be changed even if you change the display name of SharePoint column.

The internal name is not visible to users in the SharePoint user interface by default, but it is commonly used in various scenarios, such as in SharePoint REST APIs, Power Automate flow expressions, Power Apps formulas, PowerShell, etc. to interact with column data programmatically.

Where are Internal names of SharePoint columns used?

  1. Custom Scripts: When creating custom scripts, such as JavaScript or PowerShell, the internal names of columns are required to reference and manipulate the values of the columns while interacting with SharePoint data.
  2. Workflows: In SharePoint Designer workflows or Microsoft Power Automate (formerly known as Microsoft Flow), the internal names of columns are used to reference the values of the columns as inputs or outputs in the workflow actions and in expressions.
  3. Custom Solutions: When building custom solutions, such as SharePoint apps, SharePoint framework (SPFx) web parts, or custom code, the internal names of columns are required to interact with the columns programmatically.
  4. Power Apps: Few of the Power Apps functions like ShowColumns, SortByColumns, etc. requires using internal names of SharePoint columns in formula.
  5. JSON Formatting: Internal name of SharePoint column is required in JSON formatting to reference the column value with [$InternalNameOfColumn] syntax.

How to find the Internal name of a SharePoint column?

Using Modern experience list view

You can use sorting or filtering options from SharePoint online modern experience list view to find the internal name of a SharePoint column. Sort by and Filter by options are supported by most of the column types in SharePoint like Single line of text, Choice, Number, Date and Time, Yes/No (Boolean), Person or Group (single selection), etc.

For this afticle, we will use sorting based on SharePoint choice column as an example:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on column name/header from the list view and select either Ascending (A to Z) or Descending (Z to A) option from the popup menu:

Find internal name of SharePoint column by sorting choice column from SharePoint online modern experience list view
Find internal name of SharePoint column by sorting choice column

3. SharePoint will sort the list view based on selection and the browser URL will be changed like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?sortField=ChoiceColumn&isAscending=false

Where column name (ChoiceColumn) after sortField= is the internal name of your SharePoint choice column.

4. Similarly, when you use Filter by option in SharePoint modern experience to filter the list view based on Date and Time column (named as Start Date), SharePoint changes browser URL like:

https://contoso.sharepoint.com/sites/wlive/Lists/InternalNames/AllItems.aspx?FilterField1=Start_x0020_Date&FilterValue1=2023-04-05&FilterType1=DateTime

Where column name (Start_x0020_Date) after FilterField1= is the internal name of your SharePoint date and time column. Notice _x0020_ in internal column name which is an Unicode encoding of the space character in the display name of date and time column (Start Date).

Using Classic experience List settings page

Few of the SharePoint column types like Multiple lines of text, Hyperlink or Picture, Image, etc. does not support sorting or filtering from SharePoint modern experience list views. So, you have to use the classic experience list settings page to find the internal name for such SharePoint columns.

Follow below steps to find the internal name of multiple lines of text column using SharePoint classic experience list settings page:

1. Go to the SharePoint online list for which you want to check the internal name of a column.

2. Click on Settings (gear) icon from the top right corner and select List settings:

Open SharePoint online List settings page from modern experience list view to find the internal name of SharePoint column
Open SharePoint online list settings page

3. From list settings page, scroll down to the Columns section and click on the column name for which you want to find the internal name:

Open SharePoint online column settings page from classic experience list settings page to find the internal name of SharePoint column
Open SharePoint online Column settings page

4. SharePoint will open column settings page for the respective column with browser URL like:

https://contoso.sharepoint.com/sites/wlive/_layouts/15/FldEdit.aspx?List=%7B6FBA7FAE-AFC0-45D6-99EE-0AB20629EE41%7D&Field=MultilineTextCol
SharePoint online column settings page showing internal name of column
SharePoint online column settings page showing internal name of column

Where column name (MultilineTextCol) after Field= is the internal name of your SharePoint online multiple lines of text column.

Note: You can use this classic experience method to find out the internal name of SharePoint columns for all column types.

Using SharePoint REST API

You can use SharePoint REST API endpoint like below to get the internal name of SharePoint column based on it’s display name. Open URL in below format directly from browser tab:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/lists/getbytitle('InternalNames')/fields?$select=Title,InternalName&$filter=Title eq 'Multiline Text Column'
Find internal name of SharePoint online list column using SharePoint REST API
Find internal name of SharePoint column using SharePoint REST API
Using PnP PowerShell

You can use below PnP PowerShell script to find the internal name of SharePoint online list column using PnP PowerShell:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Connect to SharePoint online site
Connect-PnPOnline -Url $siteUrl -Interactive
 
# Get internal name of SharePoint list column
Get-PnPField -Identity $columnName -List $listName | Select Title,InternalName
Find internal name of SharePoint online list column using PnP PowerShell
Find internal name of SharePoint column using PnP PowerShell
Using CLI for Microsoft 365

You can use below CLI for Microsoft 365 script to find the internal name of SharePoint online list column using CLI for Microsoft 365:

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

# Display name of SharePoint list
$listName = "InternalNames"

# Display name of SharePoint list column
$columnName = "Multiline Text Column"
 
# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
	m365 login
}

# Get internal name of SharePoint list column
m365 spo field get --webUrl $siteUrl --listTitle $listName --title $columnName --output text
Find internal name of SharePoint online list column using CLI for Microsoft 365
Find internal name of SharePoint column using CLI for Microsoft 365

Best practices for naming SharePoint columns

When creating columns in SharePoint, it’s important to follow best practices for column naming to avoid using special characters or Unicode characters in internal names. Here are some recommended best practices:

  1. Use only alphanumeric characters: Stick to using letters (A-Z, a-z) and numbers (0-9) in column names. Avoid using special characters such as @, #, $, %, _, etc. Avoid column names beginning with numbers.
  2. Avoid spaces: Use PascalCase to separate words in column names instead of spaces. For example, use ColumnName instead of Column Name. This can help prevent issues with URLs, Unicode encoding, and referencing column names in scripts or code.
  3. Avoid reserved words: SharePoint has reserved words that are used for system functionality, and using them in column names may cause conflicts. Examples of reserved words include “ID”, “Modified”, “Created”, “Title”, etc. Avoid using these reserved words as column names.
  4. Keep it concise and meaningful: Use descriptive and meaningful names for columns that clearly indicate their purpose. Avoid using vague or generic names that may be confusing or ambiguous to users. Use column description to provide more information about the columns.
  5. Be consistent: Establish a consistent naming convention for columns across your SharePoint site or site collection to ensure uniformity and ease of management. This can also help with documentation, training, and maintenance of your SharePoint environment.

I hope you liked this article. Give your valuable feedback & suggestions in the comments section below and share this article with others.

Learn more

find-internal-name-of-sharepoint-column-by-sorting-choice-column

ganeshsanapblogs

Find internal name of SharePoint column by sorting choice column from SharePoint online modern experience list view

Open SharePoint online List settings page from modern experience list view to find the internal name of SharePoint column

Open SharePoint online column settings page from classic experience list settings page to find the internal name of SharePoint column

SharePoint online column settings page showing internal name of column

Find internal name of SharePoint online list column using SharePoint REST API

Find internal name of SharePoint online list column using PnP PowerShell

Find internal name of SharePoint online list column using CLI for Microsoft 365

SharePoint JSON formatting: Check if date & time column is blank/empty

SharePoint JSON formatting is a great way to customize how columns/fields are displayed in SharePoint list/library views. Many times you want to customize SharePoint list columns (like Status or Expiry of list item) based on other date & time columns in your list. While doing so, when you try to check if date & time column is blank/empty using below expression, it won’t work as expected:

"txtContent": "=if([$DueDate]) == '', '', [$DueDate])"

So, to check if date & time column is blank/empty using SharePoint JSON formatting, you have to use either of below workarounds:

Using Number() function

You can use Number(DateTimeColumn) == 0 to check if the date & time column is blank or not.

Example
{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if(Number([$DueDate]) == 0, 'Blank Date', if([$DueDate] < @now, 'Expired', 'Active'))",
    "attributes": {
        "class": "=if(Number([$DueDate]) == 0, 'sp-field-severity--warning', if([$DueDate] < @now, 'sp-field-severity--blocked', 'sp-field-severity--good'))"
    }
}

Where [$DueDate] is an internal name of your SharePoint date and time column.

Output
SharePoint JSON formatting - Check if date and time column is blank or empty
SharePoint JSON formatting – Check if date and time column is blank or empty

You can also find above JSON at list formatting samples on GitHub: Formatting a column when a date column is blank

Using toString() function

You can use toString(DateTimeColumn) == '' to check if the date & time column is blank or not.

Example
{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if(toString([$DueDate]) == '', 'Blank Date', if([$DueDate] < @now, 'Expired', 'Active'))",
    "attributes": {
        "class": "=if(toString([$DueDate]) == '', 'sp-field-severity--warning', if([$DueDate] < @now, 'sp-field-severity--blocked', 'sp-field-severity--good'))"
    }
}

Simplest way

You can also check if date & time column is blank/empty using below JSON:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if(@currentField, @currentField, 'Blank Date')",
    "attributes": {
        "class": "=if(@currentField, 'sp-field-severity--good', 'sp-field-severity--warning')"
    }
}
Output
SharePoint JSON formatting - Check if date and time column is blank or empty
SharePoint JSON formatting – Check if date and time column is blank or empty

Learn More

Download Image from SharePoint Image column using JSON formatting

In my previous blog about image columns in SharePoint, I explained all you need to know about New Image column type in SharePoint online including how to create an image column, how to add image to a list item, where the Images will be stored, etc.

You can add one image per SharePoint list item using SharePoint image column and the images are stored in Site Assets library by default. Using SharePoint online out of the box capabilities, there is no way to download the images from SharePoint list image column. In this blog, I will demonstrate how to create add a button within a SharePoint Online/Microsoft Lists modern experience view which downloads the image from SharePoint image column.

You can use below JSON to add a button in SharePoint online list column to download the image from image column in same list. This JSON formatting can be applied to any existing column in your SharePoint online list OR if you want to create a new column and then apply JSON formatting, follow the steps given in this blog: Working with SharePoint Online/Microsoft List Comments using JSON Formatting 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"style": {
"border-radius": "5px",
"margin": "5px 0px",
"padding": "0px",
"border": "none",
"display": "=if([$Image.serverRelativeUrl]=='','none','')"
},
"attributes": {
"class": "ms-bgColor-themePrimary"
},
"children": [
{
"elmType": "a",
"style": {
"text-decoration": "none",
"padding": "12px 0px",
"width": "100%"
},
"attributes": {
"href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+if([$Image.serverRelativeUrl],[$Image.serverRelativeUrl],@currentWeb+'/Lists/**YOUR-LIST-NAME**/Attachments/'+[$ID]+'/'+[$Image.fileName])",
"target": "_blank",
"class": "ms-fontColor-white ms-fontSize-m"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "Download"
}
},
{
"elmType": "span",
"txtContent": "Download"
}
]
}
]
}

Where [$Image] is the internal name of your SharePoint image column. Also, make sure to edit the above JSON and replace the **YOUR-LIST-NAME** placeholder with your list’s name, as it appears in the list URL (including special characters).

This SharePoint JSON formatting code adds a button within a SharePoint Online/Microsoft Lists modern experience view which downloads the image from SharePoint image column:

Download Image from SharePoint Online Modern experience Image column using JSON formatting
Download Image from SharePoint Image column using JSON formatting

Above JSON is also available on GitHub in PnP List Formatting Repository at: Download Image from SharePoint Image column.

Learn More

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] &lt;= @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

SharePoint Online: Apply JSON View formatting using SharePoint REST API

JSON View formatting in SharePoint Online can be a useful tool for customizing the way list/library data is presented to end users. This can help improve the user experience and make it easier for users to understand and interact with the SharePoint list/library data.

In this blog post, we will discuss how to apply JSON View formatting in SharePoint Online using SharePoint REST API.

If you want to reuse the JSON view formatting from existing SharePoint list view to newly created views in same SharePoint online list or in different SharePoint list with similar columns, you can get the custom JSON formatting applied on existing SharePoint list view using SharePoint REST API. You have to use the REST endpoint in below format to fetch the JSON:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/lists/getbytitle('My List')/views/getbytitle('All Items')?$select=Title,CustomFormatter

Once you get the list view formatting JSON using above API call, you can use it in below example to apply JSON View formatting to newly created SharePoint Online lists. For this blog post, we will reuse the JSON view formatting from one of my blog posts – SharePoint Online: Highlight selected list item rows using JSON formatting

You can use below SharePoint REST API code for applying JSON view formatting to SharePoint online list:

/sites/SPConnect/SiteAssets/jquery.min.js
<script type="text/javascript">
    function updateViewJSONFormatting(listName, viewName) {
        var viewEndpoint = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/views/getbytitle('" + viewName + "')";

        var jsonFormatting = {
			"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
			"additionalRowClass": "=if(@isSelected, 'ms-bgColor-themePrimary ms-fontColor-white', '')"
		};
        
        var viewProperties = {
            "__metadata": {
                "type": "SP.View"
            },
            "CustomFormatter": JSON.stringify(jsonFormatting)
        };

        $.ajax({
            url: viewEndpoint,
            type: "POST",
            headers: {
                "accept": "application/json;odata=verbose",
                "content-type": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                "X-HTTP-Method": "MERGE",
                "If-Match": "*"
            },
            data: JSON.stringify(viewProperties),
            success: function(data) {
                console.log(data);
            },
            error: function(error) {
                console.log(error);
            }
        });
    }
</script>

You can call above reusable function like:

updateViewJSONFormatting('Comments List', 'All Items')

Once above function executes successfully, navigate to your SharePoint online list view and you will see that JSON view formatting is applied to your SharePoint online list view:

SharePoint Online: Apply JSON View formatting using SharePoint REST API to highlight selected list item rows using JSON formatting
SharePoint Online: Apply JSON View formatting using SharePoint REST API

Learn more

highlight-selected-list-item-row-using-json-formatting-in-sharepoint

ganeshsanapblogs

SharePoint Online: Apply JSON View formatting using SharePoint REST API to highlight selected list item rows using JSON formatting

❌
❌