Skip to main content

createChoiceOptionResolver

@spartanfx/react v1.2.2


@spartanfx/react / codeapps / createChoiceOptionResolver

Function: createChoiceOptionResolver()

function createChoiceOptionResolver(
service,
columnName,
config?): ICAChoiceOptionResolver;

Build a caching resolver for a SharePoint Choice / Lookup / Person column.

The resolver calls service.getReferencedEntity("", columnName) once, caches the result, and returns the expanded option object on subsequent calls. Use the returned object's resolve method inside your writeMap (when wrapping a generated service) or pass the resolver to a hook that supports automatic resolution.

Parameters​

service​

ICAReferenceableService

The generated tabular service (or any object exposing getReferencedEntity).

columnName​

string

The SharePoint column name (e.g. "Status").

config?​

IResolverConfig = {}

Optional matcher override and debug flag.

Returns​

ICAChoiceOptionResolver

Example​

const statusResolver = createChoiceOptionResolver(TasksService, 'Status');
await statusResolver.preload(); // optional eager load

const expanded = await statusResolver.resolve('InProgress');
// expanded → { '@odata.type': '#...', Value: 'InProgress', Id: 2 }

await TasksService.create({ Title: 'Foo', Status: expanded } as never);