Marketing
Update mapped marketing-expense fields
/a/MarketingExpense_updateData
Patch mapped marketing-expense fields with conversion, strict date validation, and field history.
When to use this endpoint
Use MarketingExpense_updateData for CRM2 edits or when changing several expense fields together. Omitted fields remain unchanged.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login but performs no additional Marketing-page, create, edit, delete, or role-permission check.
All reads and writes use the authenticated tenant’s tables. CRM1 and CRM2 hide some controls through client-side permissions; these routes do not repeat those UI checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible or native array | Yes | Marketing-expense ID. Prefer a scalar ID because the shared multi-row updater discards individual errors. |
source | Integer-compatible | No | Marketing-source ID. It is integer-converted but the endpoint does not verify that the source exists. Omission during creation leaves the database default 0. |
expense | Numeric-compatible | No | Expense amount converted with floatval(). Omission during creation leaves the database default 0. |
expenseDate | Date string | No | Expense date in exact YYYY-MM-DD form. Blank is accepted; other invalid dates are rejected by mapped create/update routes. |
createDate | Unix timestamp or date string | No | Creation time stored as a Unix timestamp. Creation defaults to the current server time. |
lastEdited | Unix timestamp or date string | No | Edit time stored as a Unix timestamp. Creation defaults to now and ordinary updates advance it automatically. |
Example request
$result = FM_api('MarketingExpense_updateData', [
'id' => '7124',
'expense' => '450.75',
'expenseDate' => '2026-10-15',
]);
Example response
{"ok":1}
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":"missing or invalid parameter: id"} | No id key is present. |
{"error":"invalid date parameter: expenseDate"} | A nonblank date is not exact YYYY-MM-DD. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Source is integer-converted and expense is float-converted. Source existence is not checked.
- A native ID array is accepted, but individual row errors are discarded; use scalar IDs.
- Successful changes advance
lastEditedunless it is explicitly supplied.
Side effects
- Changed fields are recorded in Core history and the marketing-expense cache is invalidated.
See it in Fieldmotion
CRM1
CRM1 uses the three dedicated MarketingExpense_set* routes for inline changes.
CRM2
Open Marketing → Marketing Expenses in CRM2 and filter browser developer tools for the exact function name. Edit an Expense table cell; the shared display widget derives this update route.
Related endpoints
MarketingExpense_updateFieldreturns old data for one-field changes.MarketingExpense_getRequestedDetailsconfirms the final row.