When to use this endpoint

Use after editing price-bearing resources or linked invoice rows when job totals need refreshing.

Use Job_updateCosts first if missing resource prices/costs need enrichment; this endpoint sums saved prices and does not backfill them.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.

Job and form IDs refer to the authenticated account. Cross-account writes occur only through the stored outsourcing relationship on the routes that explicitly mirror changes.

The dispatcher also applies account/user and IP restrictions. A CRM session carrying a CSRF token must supply it through X-FMCSRF or _csrf; missing/incorrect tokens can be rejected before this handler runs.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesRequired by presence and integer-converted; no explicit positivity validation. Job lookup and write require an active job.

Example request

$result = FM_api('Job_updatePrices', ['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"}id is absent/null.
{"error":"invalid job"}No job row is read.
{"ok":1,"warning":"no change required"}No net/gross total or enabled auto-updated job_value change is needed; no write is performed.
{"error":"Unable to save job"}The primary database save failed. Successful-save history and subsequent follow-ups are not run.

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

Behaviour and edge cases

  • Resource fallback sums direct stock price×amt, schedule_of_rates2 price×amt, miscellaneous price×(qty or amt), meta.vehicle price×qty and meta.jobTimeDetails.billableHour×pricePerHour. Missing values contribute zero; malformed nonarray collections/rows are skipped.
  • Form meta.do_not_add_stock_to_job_costs excludes matching formTable-tagged direct stock rows. Saved table stock cells themselves are not directly summed into sell totals here, unlike their cost treatment in Job_updateCosts.
  • Selects one active linked invoice using the job/invoice relationship, falling back to the legacy invoice job link. If it has rows attributable to this job, those rows supply totals; otherwise resources supply both net and gross.
  • Invoice row job_id/jobID explicitly identifies ownership. Untagged rows count only when the invoice has exactly one linked job and it is this job. Rows are loaded from active invoice-row storage or legacy JSON and normalized first: missing net uses price×qty; missing gross or refreshed tax percentages can derive gross from discountOverall/net and the resolved account-category tax rate (falling back to default-taxtype). The job helper then sums normalized netPrice/net and gross. Multi-invoice relationships are not aggregated by this endpoint.
  • With no attributable invoice rows, price_net and price are both resource net: no tax is added to the fallback. With autoupdate-job-value=1, meta.job_value follows calculated net, including the invoice-derived net.
  • Requires an active job. There is no paging, batch option or optimistic locking. Malformed/scalar metadata is normalized to an empty collection; auto-updated job_value is serialized with valid JSON rather than applying SQL JSON functions to corrupt legacy text. Other valid metadata properties are retained.

Side effects

  • When totals change, performs a checked active-job UPDATE of price_net/price and optional meta.job_value with timestamps/edit marker and meetings-cache invalidation.
  • No direct job history, invoice mutation, stock movement, outsourced mirror or mail is performed. It does not create an invoice or calculate resource costs.

See it in Fieldmotion

CRM1

No direct canonical or legacy caller was found in CRM1. Job_setStock and other server-side job cost paths call this internally.

CRM2

On the job Costs page, save resource changes and filter Network for Job_updatePrices: pageJobCosts.js uses it in finalUpdate. The shared job editor also calls it when finishing related-job edits.

Related endpoints