Until some time ago there was only a replace function in list formatting, which allowed us to replace only the first occurrence of a value in a string.
Recently Microsoft released two new operators for list formatting:
- replaceAll
- split
With the replaceAll we can easily replace with all occurrences of a value in a string as in the example below, where we replace client by customer:
replaceAll has 3 parameters: field, original value, replacement value
replaceAll('fullString','value','replacement')
Sample JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "span",
"txtContent": "=replaceAll([$Title],'client','customer')"
}
Result (used in the Updated Text field):
The split operator accepts as a parameter a string and a value to split it:
=split('fullString','valueToSplit')
It outputs an array with the results, so for example, the below expression:
=split('A client trip to meet...
Source link
More About This Author
-
SharePoint and Office 365 Consultant/Developer always trying to get the best from Microsoft stack (Microsoft 365/Azure/Power Platform and related stuff).
Living in Ireland since 2018, I had previously worked in Brazil as a consultant/developer for Office 365, SharePoint and related technologies for almost 10 years.
Array
- Modern Workplace13 April 2024Power Pages and Cloud Flows – Validate user against Dataverse records based on Contact ID
- Modern Workplace6 April 2024Download SharePoint library files in Power Pages with JavaScript and Cloud flows – Improved code using jQuery & option to open PDF file in a new tab
- Modern Workplace13 March 2024Handle multiple N:N records associate and disassociate requests with JavaScript and Power Pages Web API
- Modern Workplace17 February 2024Generic JavaScript Functions to Associate and Disassociate Dataverse records using the Power Pages Web API