Skip to main content
Version: 1.1.0

normalizeRecord

@spartanfx/react v1.1.0


@spartanfx/react / codeapps / normalizeRecord

Function: normalizeRecord()

function normalizeRecord<T>(record): T;

Normalize a single record by flattening Choice/Person/Lookup objects and resolving Dataverse optionset codes to their formatted-name twin.

SharePoint side — for each top-level value:

  • object with Value (Choice/Lookup): replace with the string label.
  • object with DisplayName/Claims/Email (Person/Group): replace with the display name (fallback to email then claims).

Dataverse side — for each top-level field <name>:

  • if record[<name>] is a number AND record[<name>name] is a non-empty string, replace the numeric option-set value with the formatted-name string (the documented Dataverse Web API convention for optionset formatted-name twins).
  • lookup / owner / customer columns (_<name>_value + its @OData.Community.Display.V1.FormattedValue annotation) are surfaced as the display text under the bare logical name <name> — see resolveDataverseLookups.

Multi-value SharePoint Choice / Lookup / Person columns (arrays of reference objects) are joined into a comma-separated label string.

Plain text / boolean / date-string / null / undefined values pass through unchanged.

Returns a new object (the input is not mutated).

Type Parameters

T

T extends Record<string, unknown>

Parameters

record

T

Returns

T