Requisition orders
Set a legacy requisition target
/a/RequisitionOrder_setLink
Save a target reference without copying or allocating any stock.
When to use this endpoint
Choose the linked record through the UI picker. Use the specialised Job/Quote link operations for their extra stock behavior.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. API keys use their owner’s tenant; session dispatch applies CSRF checks. Office requisition access requires View and Edit on Requisition Order or Requisition Orders. A visible UI control is not sufficient authorization.
Tenant and TeamAccess/legacy department scope apply to headers and to the parent of each line. Deleted parents hide their lines. Scoped users can see their own unlinked requisitions; the legacy department-only rule retains its target-based visibility. There is no additional Requisition feature-entitlement check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Existing, non-deleted requisition ID in the authenticated tenant and your record scope. |
target_type | Integer-compatible | Yes | Type 0 No Link requires ID 0. Types 1 Contract, 2 Customer, 3 Quote, 4 Job, 5 Department, 6 Work Area, 7 User, 8 Vehicle and 9 Asset require an existing permitted target. Scoped roles can use only target families supported by their record policy. Generic linking does not allocate stock. |
target_id | Integer-compatible | Yes | 0 with No Link; otherwise a positive target ID validated for existence and related View/scope. Existing allocated material prevents changing destinations. |
Example request
$result = FM_api('RequisitionOrder_setLink', [
'id' => '1042',
'target_type' => '4',
'target_id' => '501',
]);
Example response
{"ok":1}
An exact no-op header setter may include warning:"No Change.". Committed follow-up failures include saved=1 and a warning; inspect saved state before retrying.
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":"permission denied"} | Required office page/action access is absent. |
{"error":"requisition order does not exist"} | The header is missing, deleted or outside the caller’s scope. |
{"error":"Processed requisitions are read-only"} | A material/header edit targets status 2. |
{"error":"Unable to save requisition. Check the saved state before retrying."} | A checked database/audit operation failed; verify saved state before replaying an uncertain request. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Explicit type=0/id=0 clears the link. Other enum targets require a valid positive reference and related View/scope. Unknown/negative target values fail.
- Changes the header target only. It does not transfer Job stock or containers. An allocated requisition cannot change destinations until material is returned; use the specialised linking endpoints for allocation.
- The header/line changes, aggregate totals and audit are checked in one tenant transaction. A failed write or audit rolls back the operation. Existing caller transactions use savepoints; the caller owns final commit. No request key deduplicates creation.
- Follow-up notifications and mentions run after the owning commit. If a follow-up fails after persistence, the response includes saved=1 and a warning; read the saved object before retrying and do not replay creation.
Side effects
- Checked header/totals/history writes with last_edited and deferred notifications/mentions/cache invalidation. Delivery remains separate from line totals; ordinary edits retain approval.
See it in Fieldmotion
CRM1
On CRM1 Requisition details change Linked To type then record; filter for RequisitionOrder_setLink. Quote-created requisitions also set their target here.
CRM2
No direct caller was found in CRM2 source. Its requisition screen uses mapped layout reads/writes instead of this legacy endpoint.
Related endpoints
RequisitionOrder_setLinkToJob— Link with Job material-allocation side effects.RequisitionOrder_setLinkToQuote— Link with Quote allocation side effects.RequisitionOrder_updateData— Set mapped target including No Link.