Marketing
Update one marketing-expense field
/a/MarketingExpense_updateField
Set one mapped marketing-expense field across one or more selected rows and return their previous stored values.
When to use this endpoint
Use MarketingExpense_updateField for a focused change with validation and old-data output, especially instead of the permissive CRM1 setters.
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 or ids | Integer-compatible or native array | Yes | One expense ID or a native array. id takes precedence. |
field | String | Yes | One exact mapped name from id, source, expense, expenseDate, createDate, and lastEdited. |
val | Field-compatible value | Yes | Replacement value. Source is integer-converted, expense float-converted, and expenseDate requires exact YYYY-MM-DD or blank. |
Example request
$result = FM_api('MarketingExpense_updateField', [
'id' => '7124',
'field' => 'expense',
'val' => '450.75',
]);
Example response
{
"ok": 1,
"oldData": [{"id":"7124","expense":"425.5"}]
}
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: field"} | field is absent. |
{"error":"missing or invalid parameter: val"} | val is absent. |
{"error":"missing or invalid field"} | The field is outside the expense map. |
{"error":"missing or invalid parameter: id/ids"} | Neither ID parameter is present. |
{"error":"invalid date parameter: expenseDate"} | The requested date is invalid. |
{"ok":"1","warning":"no change required"} | No selected row exists or all already contain the value. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
oldDatauses raw database column names and scalar values.- Source IDs are not checked against the source table.
- Changed rows receive the current server edit timestamp unless
lastEditeditself is selected.
Side effects
- Invalidates the marketing-expense cache and records one combined Core history entry for changed IDs.
See it in Fieldmotion
CRM1
No CRM1 caller was found; CRM1 calls dedicated field setters.
CRM2
The shared modal display framework can derive this one-field route; the full page normally uses MarketingExpense_updateData.
Related endpoints
MarketingExpense_updateDatapatches multiple fields.MarketingExpense_setExpenseis the less-safe legacy amount setter.