When to use this endpoint

Save the free-text notes accompanying job stock without changing stock quantities.

Read the target job first with Jobs_getSome to obtain the current values and confirm the IDs belong to the intended account.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. The request uses the authenticated account’s job IDs, not mobile app IDs.

No extra page, role, assignee, department or client-administrator check is applied by this handler.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesPhysical job ID in the authenticated account, converted with intval; must be positive.
valStringYesText written verbatim to stock_notes; blank clears it. Although the handler reads val directly without a presence guard, callers must supply it. No trim or length validation.

Example request

$result = FM_api('Job_setStockNotes', ['id'=>'1042', 'val'=>'Return unused fittings to stores.']);

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 or converts to a nonpositive integer.
No stable missing-val validation responseval is omitted; direct access can emit a PHP warning and feed an empty value to the write.
{"error":"Unable to save job"}The primary database write failed. History and dependent effects are not performed for that failed save.
{"error":"job does not exist"}The active target is missing/deleted or the existence lookup failed.

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

Behaviour and edge cases

  • Requires an active job before writing. A missing/deleted target or failed existence lookup returns job does not exist. The final UPDATE also excludes deleted jobs.
  • No stock allocation, inventory movement, quantity update, cost recalculation or outsourcing mirror occurs.
  • The primary UPDATE is checked before history and dependent effects. There is no transaction combining this field write with later cross-object effects; inspect committed-success warnings before retrying.

Side effects

  • Writes last_edited and edited_uuid with the changed fields and invalidates the meetings cache.
  • Records a job history entry. No mail is sent directly by this setter.

See it in Fieldmotion

CRM1

Open Job > Costs, edit the Stock Notes text and inspect Job_setStockNotes from pageJobCosts.js. It saves independently of stock row edits.

CRM2

No direct CRM2 caller was found in the canonical/legacy route search. CRM2’s layout-driven updates are a separate contract.

Related endpoints

  • Job_getStock reads stock usage; changing these notes does not change that usage.
  • Jobs_getSome reads selected job records before editing and verifies the stored result afterward.