Skip to content

Commit 052d530

Browse files
authored
Document some string related operators
Document how to concatenate strings and how to find the length of a string ( workaround )
1 parent cbc3656 commit 052d530

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/declarative-customization/column-formatting.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ Operators specify the type of operation to perform. The following operators are
12701270
- **abs**: returns the absolute value for a given number - _Only available in SharePoint Online_
12711271
- `"txtContent":"=abs(-45)"` results in _45_
12721272

1273-
- **length**: returns the number of items in an array (multi-select person or choice field), for all other value types it returns 1 when true and 0 when false. It does NOT provide the length of a string value. - _Only available in SharePoint Online_
1273+
- **length**: returns the number of items in an array (multi-select person or choice field), for all other value types it returns 1 when true and 0 when false. It does NOT provide the length of a string value (*see the `indexOf` workaround explained later on for such operation*). - _Only available in SharePoint Online_
12741274
- `"txtContent":"=length(@currentField)"` might result in _2_ if there are 2 selected values
12751275
- `"txtContent":"=length('Some Text')"` results in _1_
12761276
- `"txtContent":"=length('')"` results in _0_
@@ -1337,6 +1337,15 @@ Operators specify the type of operation to perform. The following operators are
13371337

13381338
See [here](#formatting-multi-value-fields) for examples.
13391339

1340+
**String related operators** - Some of the previously detailed operators can be used when working with string values
1341+
1342+
- \+
1343+
- indexOf ( *for string length workaround* )
1344+
1345+
`+` can be used when there is a need to concatenate strings, for instance : `"txtContent": "=[$column1] + ' ' + [$column2] + 'some other text"`
1346+
1347+
`indexOf` Since the operator `length` doesnt work for string value types ( it will return 1 or 0 ), `indexOf` can serve us as a nice workaround to get the length of a string, for instance: `indexOf([$column1] + '^', '^')`. We will use `'^'` or any other character we may want to use to find out the end of the string.
1348+
13401349
### operands
13411350

13421351
Specifies the parameters, or operands for an expression. This is an array of Expression objects or base values.

0 commit comments

Comments
 (0)