Skip to main content

Task Auto-Complete on Media Upload (Developer)

This feature automatically completes certain Tasks when a Media upload is created for a Job/Leg.

Feature Flag (Safe Rollout)​

Gated by customer config:

  • tasks.autoCompleteOnMediaUpload.enabled
    • default for trucking: true
    • default for non-trucking app types: false
    • tenant config can override either direction
  • optional toggles: tasks.autoCompleteOnMediaUpload.bol, tasks.autoCompleteOnMediaUpload.pod
  • Keep API media presence (bolPodEnforcement) as the canonical status blocker.
  • Keep task auto-complete on for trucking tenants unless they explicitly opt out.
  • Do not rely on task completion as a second hard blocker in mobile status transitions.

Upload contract (what mobile/web must send)​

Uploads go through:

  • POST /api/v1/media (multipart)

Required fields:

  • docs (file field)
  • refType: "leg" or "job"
  • refId: the parent _id as a string
  • type: must be normalized for automation:
    • "bol" for Bill of Lading
    • "pod" for Proof of Delivery

If type is "misc" / "document" / "signature", no auto-complete mapping will match.

Mapping rules (current)​

Server maps Media.type β†’ TaskTemplate.name:

  • bol β†’ pickup_sign_bol
  • pod β†’ delivery_pod

The service resolves templates by name, allowing either:

  • system templates: { scope: "system", parentCompany: null }
  • company templates: { parentCompany }

Then it finds matching pending tasks on that same parent (job/leg) and completes them.

Where it lives (API)​

  • Service: src/services/tasks/task-auto-complete.service.js
  • Wired in: src/controllers/media.js (after successful upload)

Mobile wiring notes​

In mobile, ensure the upload call ultimately hits POST /media with:

  • refType: "leg", refId: <legId>, and type: "bol" | "pod" for Load documents.
  • If uploading a BOL/POD signature, set type to "bol" / "pod" (not only "signature").