When to use this endpoint

Use MarketingExpense_setSource only for CRM1’s table editor. The mapped alternatives provide conversion, history, and old values.

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

ParameterTypeRequiredDescription
idNumeric SQL valueYesExpense-row ID. Presence only is checked; send a positive integer string.
valNumeric SQL valueYesReplacement source ID. Presence only is checked and source existence is not verified.

Example request

$result = FM_api('MarketingExpense_setSource', [
	'id' => '7124',
	'val' => '30125',
]);

Example response

{"ok":1}

Errors and unusual responses

ResponseCondition
{"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 expense/source ID is unknown or the database update fails; the query result is ignored.

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 advances the server Unix last_edited timestamp.
  • No referential, row-existence, or no-change 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 a Source cell, select another source, and leave the control.

CRM2

CRM2 uses MarketingExpense_updateData for this field.

Related endpoints