Notification rules
Edit notification-rule fields
/a/NotificationType_updateData
Save the tenant rule consumed by later notification scheduling.
When to use this endpoint
Use an existing rule ID from NotificationTypes_getDataTable, or create a disabled rule before enabling a fully configured delivery.
Authentication and permissions
Use signed API-key authentication or a logged-in CRM session on the account’s routed host. API keys act as their owner; normal session requests need dispatcher CSRF protection where configured. Tenant data is selected from the authenticated account.
The handler has no additional page-action/Role check. A CRM2 screen hiding a control does not add such a server guard, and CRM2 role names must not be assumed to apply to CRM1. The dispatcher has no dedicated object-scope mapping for this namespace.
For tableName=quoteRecurring, create/full/eligible inline updates invoke the recurrence guard: recurringQuotes must be enabled and its existing Quotes View permission helper must pass. That helper is not replaced with a new CRM2-only rule here. Other notification catalogue routes have no comparable capability gate.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible or native list | Yes | Use notification-rule IDs. Full id lists process sequentially; inline id wins over ids. JSON-encoded ID text is not decoded. |
Rule fields | Mapped values | No map-required fields | name, subject, body, recipient (JSON), replyTo, tableName, status, type, format, meta (JSON), cdate and lastEdited. name/replyTo/tableName have storage varchar(100) limits, without equivalent route-owned length checks. id is also in the low-level map. type 0 Create, 1 Update, 2 Time; status 1 enabled (0 disabled); current scheduling workers consume format 0 Email or 3 Push. These are conventions, not an enum allowlist in ordinary writes. |
meta / recipient | JSON object or encoded JSON | No | recipient describes delivery targets (for example user/creator/previousUser for Push). meta can hold filter rules, when.source, when.hours and platform. Supply a complete supported configuration from the CRM editor; whole JSON replaces, not merges, on full edits. Saving does not itself deliver a notification. |
Example request
$result = FM_api('NotificationType_updateData', ['id'=>'18','name'=>'Updated rule','status'=>'0']);
Example response
{
"ok": 1
}
Application errors normally remain JSON responses with HTTP 200; inspect error/warning keys. Numeric driver values can be strings.
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"Unable to update record"} | Primary mapped persistence fails. |
{"error":"Recurring Quotations are not enabled for this account"} | quoteRecurring guard lacks the account feature. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Omitted/native-null optional mapped fields are skipped. Blank text is saved; blank date/datetime/JSON clears to SQL NULL where mapped. Numeric values integer/float-convert. Real date fields receive calendar validation, but ordinary datetime strings have no equivalent strict check. Unknown keys are ignored by the primary mapped write.
- quoteRecurring rules only support format 0, type 2 and when.source nDate/eDate. Filters must be a native list of at most 100 safe mapped rules; hours must be a nonempty list of at most 64 numeric finite offsets with absolute value <=87600. sqlFilter is removed and evaluated safely by its worker. This does not apply the same validation to ordinary rules.
- Saving changes configuration only. Event/time workers later select enabled rules by object type, trigger kind and format; notification_types site settings for older notifications are a separate configuration store.
- If meta.filter is present, converts filter IDs to storage mappings in idOrg. For time rules, create tries compiling sqlFilter using request table_name (snake case), while mapped storage uses tableName; update compiles using the saved table_name and saved type, before applying new values.
- No-op writes return warnings instead of a fresh ID. Full ID batches stop on errors with updatedIds/failedId and can hide non-error warnings. No transaction spans the batch and configuration history.
Side effects
- Changed mapped values stamp last_edited, invalidate the table cache and write field-change history. Primary UPDATE acknowledgement is checked; history and later service calls are not one atomic save. No automatic retry/idempotency token is provided.
- Adds normalized before/after notification history when a scalar rule snapshot exists. format 3 is logged as push, other formats as email. Unchanged snapshots suppress the configuration-history entry; ordinary mapped field history is separate. No delivery/queue refresh is guaranteed by this save.
See it in Fieldmotion
CRM1
Settings > Notifications Email/Push uses mapped notificationType requests; Push requires the UI pushNotifications feature. UI-required names/subjects are stronger than the generic server map.
CRM2
Settings > Notifications, Email/Push: create/edit, inline status, Copy and Delete use the shared notificationType module and these routes. Inspect the request’s tableName/type/format and encoded recipient/meta.
Related endpoints
NotificationTypes_getDataTable— Find rule IDs and configuration.NotificationType_copy— Continue the related read/write workflow.Notifications_getHistory— Inspect configuration changes.