Skip to main content

useCADataversePlanner

@spartanfx/react v1.2.2


@spartanfx/react / codeapps / useCADataversePlanner

Function: useCADataversePlanner()

function useCADataversePlanner(config): ICAPlannerReturn;

Power Apps Code Apps Planner hook backed by a Dataverse table.

Configuration

Required

PropertyTypeDescription
idColumnstringLogical name of the primary key column on the Dataverse table — usually <entity>id (e.g. cr1a3_taskid). Must match the schema's idField.fieldName value supplied to the Planner.
schemaIPlannerSchemaSchema mapping internal planner fields to data source columns.
serviceICATabularService<CAPlannerRecord, string>Generated tabular service from pac code add-data-source.

Options

PropertyTypeDescription
autoRefresh?booleanEnable auto-refresh after mutations (default: true).
cacheDuration?numberCache TTL for read results in ms (default: 60_000).
choiceColumns?string[]SharePoint-only: column names backed by Choice / Lookup / Person columns. The Planner schema is consumer-driven (it doesn't know which columns are Choice columns), so declare them here to enable automatic expansion of string labels to the { "@odata.type", Value, Id } object the SharePoint connector requires on create/update. No default — when omitted, no resolution is performed. Ignored for services that don't expose getReferencedEntity (e.g. Dataverse). See: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/sharepoint-operations
debounceMs?numberDebounce delay for refetch on date-range change (default: 300 ms).
debug?booleanEnable verbose console logging (default: false).
endDate?DateInitial end of the visible range. Default: Dec 31 of current year.
odataFilter?stringAdditional OData $filter to combine with the date-range clause.
retryPolicy?ICARetryPolicyRetry policy for transient failures.
rowLimit?numberMaximum records per fetch (default: 5000).
searchText?stringOptional search text for client-side filtering.
startDate?DateInitial start of the visible range. Default: Jan 1 of current year.

Events & callbacks

PropertyTypeDescription
onError?(error) => voidError callback. Called for every operational failure.
onNotify?CANotifyFnNotification callback. If omitted, hook errors surface via error state only.

Full type reference: IUseCADataversePlannerConfig

Returns

ICAPlannerReturn

Example

import { ProjectsService } from './generated/services/ProjectsService';
import { useCADataversePlanner } from '@spartanfx/react/codeapps';

const plannerProps = useCADataversePlanner({
service: ProjectsService as any,
idColumn: 'cr1a3_projectid',
schema: {
idField: { fieldName: 'cr1a3_projectid' },
titleField: { fieldName: 'cr1a3_title' },
startDateField: { fieldName: 'cr1a3_startdate' },
endDateField: { fieldName: 'cr1a3_enddate' },
groupField: { fieldName: 'cr1a3_department' },
},
startDate: new Date(2026, 0, 1),
endDate: new Date(2026, 11, 31),
});

return <Planner {...plannerProps} viewBy={ViewBy.month} periodCount={PeriodCount.one} />;