Opportunities
Set an opportunity customer
/a/Opportunity_setCustomer
Replace an opportunity’s customer ID through the legacy inline-edit route.
When to use this endpoint
Use Opportunity_setCustomer only for compatibility with legacy inline editors. Current CRM2 code uses Opportunity_updateData.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Opportunity ID after integer conversion. |
val | Integer string | Yes | Replacement customer ID. Blank/non-numeric values become zero. |
Example request
$result = FM_api('Opportunity_setCustomer', [
'id' => '481',
'val' => '1042',
]);
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 omitted. |
{"error":"missing or invalid parameter: val"} | val is omitted. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The route does not verify that either row exists, exclude soft-deleted opportunities, or validate the customer/its active state. No-op updates still return success.
- It checks no feature or edit permission beyond login.
Side effects
- Sets
customer_id, updateslast_editedto the current epoch, and invalidates the opportunities cache. - Does not write audit history or send opportunity notifications.
See it in Fieldmotion
CRM1
No current direct CRM1 caller was found; the legacy table does not expose customer inline editing.
CRM2
CRM2 updates the customer/customerID mapped field through Opportunity_updateData.
Related endpoints
Opportunity_updateDataprovides audited mapped updates.Opportunity_getreturns the storedcustomer_id.