When to use this endpoint

Use ScheduleOfRates_setCode for CRM1 inline code editing.

Authentication and permissions

The request must establish tenant context with signed API credentials or a logged-in CRM session. The handler checks for the tenant database prefix rather than calling the normal login guard.

No additional page or role permission is checked. The CRM screens apply their own client-side Schedule of Rates permissions.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesPositive rate ID.
valStringYes in practiceComplete replacement after trimming. Blank and duplicate codes are accepted. Omission is not explicitly validated.

Example request

FM_api('ScheduleOfRates_setCode', [
	'id' => '430001',
	'val' => 'AS-02',
]);

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"}The ID is absent or not positive.
{"error":"schedule of rates does not exist"}The ID has no row.
{"ok":1,"msg":"no change needed"}The trimmed value exactly matches the stored code.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • No uniqueness or length check is applied.
  • There is no filtering or pagination; one row is read and conditionally updated.

Side effects

  • On change, advances last_edited and the scheduleOfRates cache marker.
  • Fires the tenant-configurable SOR_edit event with the rate ID. Any configured listeners run synchronously and can add integration-specific side effects.

See it in Fieldmotion

CRM1

Click the Code cell on the Schedule of Rates page and blur the editor.

CRM2

CRM2 changes code through ScheduleOfRate_updateData.

Related endpoints