Requisition orders
Allocate requisition stock to a Quote
/a/RequisitionOrder_setLinkToQuote
Move available requisition container quantities to the linked Quote target.
When to use this endpoint
Use after mapped line creation has produced initial order_containers and the Quote already contains material cost rows. This reads the Quote’s costs; it does not copy the requisition line list into the Quote.
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.
The destination also requires its own View and Edit permission and record scope, checked before material or allocation writes.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Existing, non-deleted requisition ID in the authenticated tenant and your record scope. |
quoteID | Integer-compatible | Yes | Positive existing non-deleted Quote in the caller’s scope, with Quote View and Edit permission. |
Example request
$result = FM_api('RequisitionOrder_setLinkToQuote', [
'id' => '1042',
'quoteID' => '701',
]);
Example response
{"ok":1}
Missing Quote costs/stock returns a warning without linking. A valid empty list returns ok; insufficient stock returns an error and rolls back.
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. |
{"error":"Insufficient requisition stock for destination"} | Requested material exceeds available initial and matching destination allocations. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- A Quote without meta.costs returns {warning:"missing costs"}; one without costs.stock returns {warning:"missing stock"}. Neither warning links the header. An empty stock list may link without material movement. JSON strings and native arrays are accepted for these stored structures.
- Accepts both id and legacy sid on stock rows. Both present with different IDs fail. Rows without either identity are ignored. Amounts are nonnegative whole numbers and duplicate stock identities are summed.
- Allocates exactly the requested quantity from the requisition’s initial type-15 containers into Quote type-12 containers. Existing allocations to the same Quote count toward the request; repeats do not duplicate them. Shortages or another destination reject the operation.
- All allocation changes and the header target/type/last_edited/history are checked in one transaction. A later header/audit error rolls back earlier container changes; no partial allocation is presented as success.
- 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.
Side effects
- Atomically writes Quote container allocations and requisition target/timestamp/history; invalidates the requisition cache. Quote financial rows and physical stock levels are unchanged.
See it in Fieldmotion
CRM1
No direct caller was found in CRM1 source. Its requisition screen uses the legacy header/line endpoints instead.
CRM2
On CRM2 Requisition details choose Linked To → Quote and Save. After Layout_setValue, the client calls RequisitionOrder_setLinkToQuote with id/quoteID; filter for both requests.
Related endpoints
RequisitionOrderEntry_createData— Create initial requisition container rows.RequisitionOrder_setLink— Set only a reference with no allocation.RequisitionOrder_setLinkToJob— Use the separate Job-material workflow.