Read-only building blocks for record pages: a status badge, a postal address, choice values with their colors, and a way to read a column's value in code without decoding the wire format.
To branch on a value (tint a status, show a flag, compare a date), read the column's raw value instead of its label, which is localized. In React, useColumnValue(columnName) returns the value of a column of the surrounding RecordContext as a plain JavaScript type, with the formatted string and the column's metadata alongside it. In Blazor, read the typed value from the record with GetValueOrDefault<T>. Either way, a column that is empty or withheld by column security reads as null; CanReadColumn tells the two apart.
function OpenMessage() {
const { raw: state } = useColumnValue<number>('statecode');
return state === 0 ? <p>This case is still open.</p> : null;
}
<RecordContext table="incident" queryParameterName="id">
<OpenMessage />
</RecordContext><RecordContext TableName="incident" QueryParameterName="id">
<ContextTemplate>
@if (IsActive(context))
{
<p>This case is still open.</p>
}
</ContextTemplate>
</RecordContext>
@code {
// Value is null when the column is empty or withheld, so null never counts as active.
private static bool IsActive(TableRecord record)
=> record.GetValueOrDefault<ChoiceValue>("statecode")?.Value == 0;
}Outside a RecordContext, such as in a grid cell renderer or a chart tooltip, call readColumnRawValue(record, columnName) from @powerportalspro/core on the record you hold.
ColumnStatusBadge shows the record's status reason (statuscode) and takes its color from the state (statecode): a brand tint while active, a neutral outline otherwise. The color comes from the state's value, not its label, so it holds in every language. Nothing renders when the label is empty or withheld.
For a table with more than two states, pass a Tone function that maps the state's value to a badge color and appearance. It receives null when the state is empty or withheld.
<ColumnStatusBadge
tone={(state) =>
state === 0 ? { color: 'success', appearance: 'tint' }
: state === 1 ? { color: 'informative', appearance: 'outline' }
: { color: 'danger', appearance: 'tint' }}
/><ColumnStatusBadge Tone="@(state => state switch
{
0 => new StatusBadgeTone(BadgeColor.Success, BadgeAppearance.Tint),
1 => new StatusBadgeTone(BadgeColor.Informative, BadgeAppearance.Outline),
_ => new StatusBadgeTone(BadgeColor.Danger, BadgeAppearance.Tint),
})" />AddressDisplayValue renders one of a table's addresses (address1, address2, …) in an <address> element, with the same label as ColumnDisplayValue. It shows Dataverse's _composite column when the user may read it. Otherwise it composes the street lines, then city, region and postal code, then the country, which it leaves off when it matches HomeCountry.
With ShowMap (Blazor) or showMap (React) on, a pin in the address's top right corner opens it on the portal's map, in a dialog. When the record has the address's coordinates ({prefix}_latitude and {prefix}_longitude, or the columns LatitudeColumn and LongitudeColumn name) the pin is placed there; otherwise the map provider's own search finds the address as the dialog opens, with a spinner while it looks. Here the head office has its coordinates and the branch office is found. Coordinates left behind by an edited address aren't used.
The map comes from the Maps package: register it once with AddPowerPortalsProWebBlazorMaps() in Blazor, or put <MapsProvider> from @powerportalspro/react-maps around the app in React. To keep the coordinates up to date as addresses are saved, turn on geocoding.
<PowerPortalsProProvider>
<MapsProvider>
<RouterProvider router={router} />
</MapsProvider>
</PowerPortalsProProvider>
<AddressDisplayValue prefix="address1" showMap />// Program.cs — and a WebAssembly client's Program.cs, when its pages show the address
builder.Services.AddPowerPortalsProWebBlazorMaps();
<AddressDisplayValue Prefix="address1" ShowMap="true" />With DisplayChoiceColors (Blazor) or displayChoiceColors (React) on, ColumnDisplayValue shows the color each option of a choice or multi-select choice column is given in Dataverse as a small swatch in front of its label. It is off by default, and an option with no color shows its label alone.
Name | Type | Default | Description |
|---|---|---|---|
IsVisible | bool | True | Is the badge visible. |
LabelColumn | string | statuscode | Column whose formatted value is the badge's text. Defaults to |
Size | BadgeSize? | Badge size. Defaults to Fluent's own. | |
StateColumn | string | statecode | Column whose value decides the tone. Defaults to |
Tone | Func<int?, StatusBadgeTone>? | Picks the tone from the state column's value — null when it is empty or withheld. Defaults to Nullable{System.Int32}): a brand tint for active ( |
IsVisibleLabelColumnSizeStateColumnTonenull when it is empty or withheld. Defaults to Nullable{System.Int32}): a brand tint for active (Name | Type | Default | Description |
|---|---|---|---|
Description | string? | Description to be displayed in the tooltip. Falls back to the | |
DisplayLabelWhenAvailable | bool | True | Specifies whether to display a label if available. |
DisplayTooltipWhenAvailable | bool | True | Specifies whether to display a tooltip if available. |
EmptyPlaceholder | string | — | Text shown when the address is empty. Defaults to an em-dash; pass an empty string to suppress. |
HomeCountry | string? | The country to leave off a composed address, e.g. 'United States' for a portal whose addresses are almost all domestic. Compared ignoring case and accents. Doesn't apply when the address is Dataverse's own composite, which is shown as Dataverse formats it. | |
IsVisible | bool | True | Is the address visible. |
Label | string? | Text to be displayed as a label. Falls back to the | |
LabelPosition | EditorLabelPosition? | Where the label sits relative to the value. When null (the default) it takes the position set on the nearest enclosing EditorLabelPosition.Auto when none sets one. | |
LatitudeColumn | string? | The column holding the address's latitude, for AddressDisplayValue.ShowMap. Defaults to | |
LongitudeColumn | string? | The column holding the address's longitude, for AddressDisplayValue.ShowMap. Defaults to | |
Prefix | string | address1 | The address's column prefix — |
ShowMap | bool | False | Shows a pin button in the address's top right corner that opens it on a map, in a dialog: at the record's coordinates ( AddressDisplayValue.LatitudeColumn, AddressDisplayValue.LongitudeColumn) when it has them, and otherwise found with the map provider's search as the dialog opens. Needs the Maps package ( |
DescriptionDisplayLabelWhenAvailableDisplayTooltipWhenAvailableEmptyPlaceholderHomeCountryIsVisibleLabelLabelPositionnull (the default) it takes the position set on the nearest enclosing EditorLabelPosition.Auto when none sets one.LatitudeColumnAddressDisplayValue.ShowMap. Defaults to LongitudeColumnAddressDisplayValue.ShowMap. Defaults to PrefixShowMapAddressDisplayValue.LatitudeColumn, AddressDisplayValue.LongitudeColumn) when it has them, and otherwise found with the map provider's search as the dialog opens. Needs the Maps package (Name | Type | Default | Description |
|---|---|---|---|
ColumnName* | string | Column logical name to bind the editor to from the table record. | |
Description | string? | Description to be displayed in the tooltip. | |
DisplayChoiceColors | bool | False | Show the color each choice option is given in Dataverse as a small swatch in front of its label, for a choice or multi-select choice column shown without a ColumnDisplayValue.Format. Defaults to |
DisplayLabelWhenAvailable | bool | True | Specifies whether to display a lable if available. |
DisplayTooltipWhenAvailable | bool | True | Specifies whether to display a tooltip if available. |
Format | string? | Optional format to be applied to the value in order to calculate the display value. | |
IsVisible | bool | True | Is the editor visible. |
Label | string? | Text to be displayed as a label for the editor. | |
LabelPosition | EditorLabelPosition? | Where the label sits relative to the value. When null (the default) it takes the position set on the nearest enclosing EditorLabelPosition.Auto when none sets one. |
ColumnName*DescriptionDisplayChoiceColorsColumnDisplayValue.Format. Defaults to DisplayLabelWhenAvailableDisplayTooltipWhenAvailableFormatIsVisibleLabelLabelPositionnull (the default) it takes the position set on the nearest enclosing EditorLabelPosition.Auto when none sets one.