Skip to main content

useCADataverseNotificationCenter

@spartanfx/react v1.2.2


@spartanfx/react / codeapps / useCADataverseNotificationCenter

Function: useCADataverseNotificationCenter()

function useCADataverseNotificationCenter(config): INotificationCenterHook;

Power Apps Code Apps NotificationCenter hook backed by Dataverse.

Consumes a generated <Table>Service from pac code add-data-source -a dataverse.

Configuration

Required

PropertyTypeDescription
serviceICATabularService<CANotificationRecord, string>Generated Dataverse-table service produced by pac code add-data-source -a dataverse -t <table-logical-name>. Typically located under src/generated/services/<TableName>Service.ts.

Options

PropertyTypeDescription
schema?Partial<INotificationCenterSchema>Schema mapping for Dataverse column logical names. The defaults assume unprefixed columns — production tables almost always use a publisher prefix (e.g. cr1a3_title), so override accordingly. The primary key column must be supplied if it differs from id (e.g. notificationid for a custom notification table).

+ 11 inherited members. standard HTML/ARIA attributes (e.g. className, onClick, aria-*) are also accepted but omitted here for clarity.

Full type reference: IUseCADataverseNotificationCenterConfig

Returns

INotificationCenterHook

Example

import { NotificationsService } from './generated/services/NotificationsService';
import { useCADataverseNotificationCenter } from '@spartanfx/react/codeapps';

const hook = useCADataverseNotificationCenter({
service: NotificationsService,
schema: {
id: 'cr1a3_notificationid',
title: 'cr1a3_title',
message: 'cr1a3_message',
level: 'cr1a3_level',
isRead: 'cr1a3_isread',
},
onNotify: (level, msg) => toast[level](msg),
});
return <NotificationCenter provider={hook} />;