When to use this endpoint

Use ScheduleOfRates_setAssetTypes for CRM1’s asset-type eligibility editor. The list route uses this stored JSON-like list when a Job targets an asset.

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.
valsNative array or JSON array stringYesComplete asset-type ID list. Every member is integer-converted; zeros and duplicates are preserved. An empty list stores [].

Example request

FM_api('ScheduleOfRates_setAssetTypes', [
	'id' => '430001',
	'vals' => [7, 9],
]);

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":"missing parameter: vals"}vals is absent.
{"error":"invalid parameter: vals"}The value is not an array and does not decode to one.
{"error":"schedule of rates does not exist"}The ID has no row.
{"ok":1,"msg":"no change needed"}The existing stored JSON string exactly equals the normalized result.

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

Behaviour and edge cases

  • Asset-type IDs are not checked for existence or active state.
  • Null/unrestricted eligibility cannot be written by this endpoint; an empty array is a stored list and is treated differently from SQL null by the Job-context list query.

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

Edit Asset Types in a Schedule of Rates table row to call this endpoint.

CRM2

CRM2 uses ScheduleOfRate_updateData for the mapped assetTypes field.

Related endpoints