Marketing
Set a marketing-expense amount
/a/MarketingExpense_setExpense
Replace the amount on one marketing-expense row from CRM1’s inline table editor.
When to use this endpoint
Use MarketingExpense_setExpense only for the legacy CRM1 cell-edit workflow. The mapped field/update routes validate and record the change.
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 | Numeric SQL value | Yes | Expense-row ID. This legacy route checks presence only; callers must send a positive integer string. |
val | Numeric SQL value | Yes | Replacement expense. Presence only is checked; callers must send a database-compatible numeric string. |
Example request
$result = FM_api('MarketingExpense_setExpense', [
'id' => '7124',
'val' => '450.75',
]);
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"} | id is absent. |
{"error":"missing or invalid parameter: val"} | val is absent. |
{"ok":1} | The ID is unknown or the database rejects the update; the query result is not checked. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- An attempted update sets
last_editedto the current server Unix timestamp. - No amount range, currency, change detection, or row-existence check is performed.
Side effects
- Requests marketing-expense cache invalidation but writes no Core history.
See it in Fieldmotion
CRM1
Open Settings → Marketing → Expense in CRM1 and filter browser developer tools for the exact function name. Click an Expense cell, change the number, then leave the field.
CRM2
CRM2 uses MarketingExpense_updateData for table edits.
Related endpoints
MarketingExpense_updateFieldis the validated mapped alternative.MarketingExpense_getRequestedDetailsverifies the amount.