When to use this endpoint

StockCategory_getRequestedDetails supplies the single ID and parent before confirmation. Keep this wrapper to single-ID deletion when you need its repairs.

Categories organize stock membership and parent/child navigation; these calls do not transfer physical stock or change quantities. Select the legacy or mapped API that matches your field names.

Authentication and permissions

Authenticate using signed API-key fields or a logged-in CRM session. All object queries use the authenticated tenant. The handler has no additional page, role or feature check unless stated below.

Sign numeric request values as strings, including nested native arrays; only JSON-encode parameters that explicitly accept JSON text. See Getting started.

Parameters

ParameterTypeRequiredDescription
idPositive integerYesOne positive integer ID of an active tenant-local record; arrays, negative numbers and SQL-like strings are rejected.

Example request

$result = FM_api('StockCategory_deleteData', ['id'=>'1042']);

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"}Not one positive integer.
{"error":"category deletion requires a single id only"}Extra recognized deletion filters supplied.
{"error":"inventory deletion could not be recorded"}Audit failed; tenant writes roll back.
{"error":"inventory write failed"}Tenant persistence failed and rolled back.

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 one positive scalar id. Recognized extra mapped filters and arrays/bulk IDs are rejected; deletion cannot silently include unrelated categories.
  • A missing or already deleted positive ID returns {ok:1} without duplicate audit/events.
  • Reparents immediate active children to the previous parent and advances their timestamps. If that legacy ancestor chain is missing/cyclic, reparents to root instead.
  • Sets deleted=1, ddate to Unix time and last_edited to server datetime; records the original row in deletes under mobile key stockcategorys with app_id=0. Repairs affected active stock summaries and clears tenant stockcat mappings in the same transaction.
  • Tenant row changes, membership repairs and required audit writes are checked within one transaction; a failure rolls them back and returns an error. Configured events run only after commit.
  • Global stockcat upload-queue cleanup occurs after the tenant commit, before StockCat_edit; a failed post-commit task returns success plus a warning, not a rollback.
  • Only non-deleted categories are read or changed. No quantity, price or accounting-provider availability check is applied.
  • The source search found no direct caller in the mobile JavaScript app or its m/www intermediary for this endpoint.
  • Post-commit event failures on event-producing writes return the committed success plus warning: saved, but a configured event failed; do not repeat creation. Review the saved record before retrying.

Side effects

  • Soft-deletes and audits the category, reparents children, removes tenant accounting links and refreshes stock summaries.
  • Rebuilds affected active stock items’ category_ids as JSON text containing string IDs and categories as comma-separated names. Advances stock last_edited and sets edited_uuid to the endpoint name; invalidates stocks cache. No stock quantity movement occurs.
  • After commit, clears global stockcat upload entries and fires configured StockCat_edit.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found for this endpoint. The legacy Stock Categories screen uses StockCategory_get and StockCategories_listByParent.

CRM2

Stock Categories deletion uses the generic deleteData(table:stockCategory) helper with an id; filter StockCategory_deleteData. The maintenance category-delete list also uses this helper.

Related endpoints