Read-only building blocks for record pages: a status badge, a postal address, 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 colour from the state (statecode): a brand tint while active, a neutral outline otherwise. The colour 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 colour 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.
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 StatusBadgeTone.Default(System.Nullable{System.Int32}): a brand tint for active ( |
IsVisibleLabelColumnSizeStateColumnTonenull when it is empty or withheld. Defaults to StatusBadgeTone.Default(System.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 | |
Prefix | string | address1 | The address's column prefix — |
DescriptionDisplayLabelWhenAvailableDisplayTooltipWhenAvailableEmptyPlaceholderHomeCountryIsVisibleLabelPrefix