Skip to main content

useCASharePointDocumentManager

@spartanfx/react v1.2.2


@spartanfx/react / codeapps / useCASharePointDocumentManager

Function: useCASharePointDocumentManager()

function useCASharePointDocumentManager(config): IUseCASharePointDocumentManagerReturn;

Power Apps Code Apps DocumentManager hook backed by a generated SharePoint document-library service.

The normal Code Apps path is to pass the generated service produced by pac code add-data-source directly. The hook maps the synthetic document-library fields ({IsFolder}, {Name}, {Path}, {FullPath}, etc.) into IDocumentItem and returns component-ready documentManagerProps.

A semantic file service implementing ICASharePointDocumentService is still supported for consumers that have non-tabular connector operations such as binary upload/download, copy, move, and folder creation.

Configuration

Required

PropertyTypeDescription
service| ICASharePointDocumentService | ICATabularService<CADocumentRecord, string>Generated SharePoint document-library service from pac code add-data-source, or a custom semantic file service for consumers that need non-tabular connector operations.

Options

PropertyTypeDescription
autoRefresh?booleanEnable auto-refresh after mutations (default: true).
cacheDuration?numberCache TTL for read results in ms (default: 60_000).
debug?booleanEnable verbose console logging (default: false).
fieldMapping?ICASharePointDocumentFieldMappingField mapping for generated SharePoint document-library services.
libraryName?stringDisplay label for the library (used in the breadcrumb).
retryPolicy?ICARetryPolicyRetry policy for transient failures.
rootFolderPath?stringServer-relative root folder path for the document library (e.g. /sites/contoso/Shared Documents). Used as the initial currentPath and for breadcrumb resolution.
rowLimit?numberMaximum records to fetch from a generated tabular service. Default: 5000.

Events & callbacks

PropertyTypeDescription
onAfterUpload?(file, item) => void | Promise<void>Called after successful upload.
onBeforeUpload?(file) => Promise<boolean | void>Called before upload; return false to cancel.
onError?(error) => voidError callback. Called for every operational failure.
onNotify?CANotifyFnNotification callback. If omitted, hook errors surface via error state only.

Full type reference: IUseCASharePointDocumentManagerConfig

Returns

IUseCASharePointDocumentManagerReturn

Example

const docs = useCASharePointDocumentManager({
service: ProjectDocumentsService as never,
libraryName: 'Project Documents',
});

return <DocumentManager {...docs.documentManagerProps} />;