useCASharePointPlanner
@spartanfx/react / codeapps / useCASharePointPlanner
Function: useCASharePointPlanner()
function useCASharePointPlanner(config): ICAPlannerReturn;
Power Apps Code Apps Planner hook backed by a SharePoint list.
Consumes a generated SharePoint-list service produced by
pac code add-data-source -a shared_sharepointonline -t <ListName> -d <siteUrl>.
Configuration
Required
| Property | Type | Description |
|---|---|---|
schema | IPlannerSchema | Schema mapping internal planner fields to data source columns. |
service | ICATabularService<CAPlannerRecord, string> | Generated tabular service from pac code add-data-source. |
Options
| Property | Type | Description |
|---|---|---|
autoRefresh? | boolean | Enable auto-refresh after mutations (default: true). |
cacheDuration? | number | Cache TTL for read results in ms (default: 60_000). |
choiceColumns? | string[] | SharePoint Choice / Lookup / Person column names that must be sent as the expanded reference object on create/update. The hook calls service.getReferencedEntity for each column and substitutes the matching option object before posting the payload. No default — the Planner schema is consumer-driven, so declare here any groupField / colorField / custom columns that map to a SharePoint Choice (or Lookup / Person) column. Example choiceColumns: ['Department', 'Priority'] See: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/sharepoint-operations |
debounceMs? | number | Debounce delay for refetch on date-range change (default: 300 ms). |
debug? | boolean | Enable verbose console logging (default: false). |
endDate? | Date | Initial end of the visible range. Default: Dec 31 of current year. |
odataFilter? | string | Additional OData $filter to combine with the date-range clause. |
retryPolicy? | ICARetryPolicy | Retry policy for transient failures. |
rowLimit? | number | Maximum records per fetch (default: 5000). |
searchText? | string | Optional search text for client-side filtering. |
startDate? | Date | Initial start of the visible range. Default: Jan 1 of current year. |
Events & callbacks
| Property | Type | Description |
|---|---|---|
onError? | (error) => void | Error callback. Called for every operational failure. |
onNotify? | CANotifyFn | Notification callback. If omitted, hook errors surface via error state only. |
Full type reference:
IUseCASharePointPlannerConfig
Returns
Example
import { ProjectsService } from './generated/services/ProjectsService';
import { useCASharePointPlanner } from '@spartanfx/react/codeapps';
const plannerProps = useCASharePointPlanner({
service: ProjectsService as any,
schema: {
idField: { fieldName: 'ID' },
titleField: { fieldName: 'Title' },
startDateField: { fieldName: 'StartDate' },
endDateField: { fieldName: 'EndDate' },
groupField: { fieldName: 'Department' },
},
startDate: new Date(2026, 0, 1),
endDate: new Date(2026, 11, 31),
});
return <Planner {...plannerProps} viewBy={ViewBy.month} periodCount={PeriodCount.one} />;