Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Canvas apps
Cards
Copilot Studio
Model-driven apps
Power Platform CLI
Dataverse functions
Retrieves column names and values from a dynamic value.
Description
The ColumnNames function returns the names of all columns from a dynamic record, returning a table with all the names from that record.
The Column function returns the value of a property from a dynamic record with the given column name. The value is returned as a dynamic value.
The ColumnNames and Column functions return errors if the dynamic value doesn't represent a record (that is, if it represents a table or a scalar or primitive value).
Syntax
ColumnNames( DynamicRecord )
- DynamicRecord – Required. A dynamic value that represents a record.
Column( DynamicRecord, ColumnName )
- DynamicRecord – Required. A dynamic value that represents a record.
- ColumnName - Required. The name of the column to be retrieved from the given record.
Examples
Accessing field values
Given the following JSON string in a variable named JsonString
{ "name": "Seattle", "population": 737000 }
The following formula returns a single-column table with a
Value
column containing the following values: "name", "population":ColumnNames( ParseJSON( JsonString ) )
The following formula returns the number
737000
:Value( Column( ParseJSON( JsonString ), "population" ) )
- Notice that this is similar to the
.
operator for dynamic records, but the column name doesn't have to be known beforehand.
- Notice that this is similar to the
The following formula returns the text value
"name: Seattle, population: 737000"
:With( { untyped: ParseJSON( JsonString ) }, Concat( ColumnNames( untyped ), $"{Value}: {Column( untyped, Value )}", ", "))
Blanks
Given the following JSON string in a variable named JsonString
{ "text": "text value" , "number": 567, "empty": null }
- Attempting to access nonexisting fields returns Blank(). The following formula returns
true
:IsBlank( Column( ParseJSON( JsonString ), "does not exist" ) )
- JSON
null
values are considered Blank(). The following formula returnstrue
:IsBlank( Column( ParseJSON( JsonString ), "empty" ) )
Nonrecords
Calling the Column or ColumnNames functions with dynamic values that don't represent records return an error. All of those expressions below are erroneous:
Formula | Reason for error |
---|---|
ColumnNames( ParseJSON ( "[1, 2, 3]" ) ) | Dynamic value represents an array |
Column( ParseJSON ( "23.45" ), "Value" ) | Dynamic value represents a number |
ColumnNames( ParseJSON ( """hello""" ) ) | Dynamic value represents a text |
Column( ParseJSON ( "{""a"":false}" ).a, "a" ) | Dynamic value represents a boolean value |