> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/product/features/assets/asset-codes.md).

# Asset codes

{% hint style="info" %}
Draft, written by an agent and not yet checked by a person ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/product/features/asset-codes.md).
{% endhint %}

An asset can carry a **QR code**, a **barcode** and a **Smart Tag** (an NFC tag). Each is an attribute value of the asset, of the type `qr`, `barcode` or `nfc`; a new register has one attribute of each kind in the category "Tracking". People add a code by scanning it with the camera in the iOS or Android app, or by holding the phone to a Smart Tag. The web shows, copies, downloads and removes an asset's codes, and has no scanner. In the apps, scanning a code finds the asset, then offers to open it or create a task for it, or, when nothing matches, to create a new asset with that code.

## Rules

### Code values

* A code is the value of an attribute whose type is `qr`, `barcode` or `nfc` ([Asset registers](https://docs.snapfix.com/product/features/assets/asset-registers.md#attributes)). A new register gets "NFC", "QR" and "Barcode" in "Tracking", none mandatory ([`POST /v1/app/asset-regs`](https://docs.snapfix.com/engineering-reference/api/assets.md#post-v1appasset-regs)).
* The web shows the first attribute of each kind as a "QR Code", "Barcode" or "Smart Tag" button, only when the register has that kind. A button is off until the asset has a value ([Asset detail](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-detail.md#attributes-web)).
* Codes are set by scanning in the apps, when attributes are filled in or edited ([Asset attributes](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-attributes.md)). The web cannot set a code.
* A QR code or barcode value is the scanned text. A Smart Tag value is the tag's serial ([Code scanner](https://docs.snapfix.com/how-the-apps-work/screens/assets/code-scanner.md#inputs)).
* In an attribute's scan row, Android's scanner reads only that attribute's kind: QR codes for a QR attribute, one-dimensional barcodes for a barcode attribute (android @ 86068bfeea, `app/src/main/java/gmail/com/snapfixapp/activity/AssetAttributesActivity.kt:307-313`). Its main scanner reads every type.
* A code is not checked for uniqueness: the default code attributes are not unique, and no screen sets the unique flag, so two assets can share a value \[[ASK-106](https://github.com/snapfix/docs/blob/main/ASK.md#ask-106-should-qr-barcode-and-smart-tag-values-be-unique-within-a-register)].
* A mandatory code needs a value before the attributes are saved, in the web and in the apps. A phone without NFC skips the check for Smart Tag attributes (both apps). The server does not check mandatory values \[[ASK-98](https://github.com/snapfix/docs/blob/main/ASK.md#ask-98-should-the-server-refuse-an-asset-save-that-leaves-a-mandatory-attribute-empty)] ([Asset attributes](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-attributes.md#inputs)).
* Any signed-in user can change any asset's values, codes included, through the API ([`POST /v1/app/assets/save-attributes`](https://docs.snapfix.com/engineering-reference/api/assets.md#post-v1appassetssave-attributes)).

### Showing, downloading and removing

* The web's code dialog shows the code picture and the value, with "Copy" ("Copied to clipboard"), "Download" and, for users who may change the asset, "Remove QR Code", "Remove Barcode" or "Remove Smart Tag" ([Code dialog](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-detail.md#code-dialog-web)).
* "Download" saves the picture as a `.jpg` file that holds PNG data. Android's code sheet on an asset saves the picture to the gallery ("Save to Gallery").
* "Remove" on the web clears the value at once, with no confirmation. The code button stays on until the page reloads. In the apps, a cleared value is kept with the attribute save ([Asset attributes](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-attributes.md#actions)).

### Scanning to find an asset

* The apps scan from the scan buttons and menus of the register list and the asset list: "Scan Asset QR or Barcode" and "Scan Asset Smart Tag" ([Code scanner](https://docs.snapfix.com/how-the-apps-work/screens/assets/code-scanner.md)).
* The lookup runs on the phone, against the synced values, so it works offline.
* iOS looks in the registers the user belongs to on the selected site, among the assets they may see (admin, "View All Tasks", creator, assignee or follower), and leaves out archived registers and archived assets (ios @ aa31967ac8, `SnapFix/Asset/ViewModel/AssetAttributeViewModel.swift:261-292`). It matches any stored value that contains the scanned text and takes the first row in no set order, and it pastes the text into the query, so a code that matches several assets opens one of them, and a code with an apostrophe finds nothing.
* Found: "Asset found. What do you want to do next?" with "View Asset" and "Create Task". Not found: "The scanned Asset does not exist in this Account. Would you like to create it?" with "Cancel" and "Create Asset" ([Code scanner](https://docs.snapfix.com/how-the-apps-work/screens/assets/code-scanner.md#actions)).
* "Create Task" and "Create Asset" need the create permission, and iOS hides the create buttons without it. A new asset starts with the scanned value in its code attribute and then asks for its attributes; a new task is linked to the asset ([Asset tasks](https://docs.snapfix.com/product/features/assets/asset-tasks.md)).
* iOS's "Search by code" on the asset list puts the scanned text into the search box.

### Smart Tags (NFC)

* A Smart Tag needs a phone with NFC. Without it, the apps say "Your device doesn't support NFC"; Android with NFC off asks to turn it on ([Code scanner](https://docs.snapfix.com/how-the-apps-work/screens/assets/code-scanner.md#inputs)).
* On iOS, the NFC scan from an asset's menu needs the site's plan feature `nfc_enabled`; the web and the server do not check it \[[ASK-23](https://github.com/snapfix/docs/blob/main/ASK.md#ask-23-should-plan-limits-be-enforced-on-the-web-and-the-server)].
* An unused web action can post an NFC scan line to a task's chat (`webcust_nfc_scan`, no caller) ([Assets API](https://docs.snapfix.com/engineering-reference/api/assets.md)).

## Flow

```mermaid
flowchart LR
    scan["Scan in the app"] --> kind{"Kind"}
    kind -- "QR or barcode" --> camera["Camera scanner"]
    kind -- "Smart Tag" --> nfc["NFC reader (phone needs NFC)"]
    camera --> lookup{"Value found on the phone?"}
    nfc --> lookup
    lookup -- yes --> found["View Asset or Create Task"]
    lookup -- no --> missing["Create Asset with the value, or Cancel"]
    row["Attribute screen: scan into a code row"] --> saved["Saved with the attributes, synced later"]
    web["Web: code dialog"] --> actions["Copy, Download or Remove"]
```

## Platforms

| Capability             | Web                     | iOS                                             | Android                                         |
| ---------------------- | ----------------------- | ----------------------------------------------- | ----------------------------------------------- |
| See an asset's codes   | Code buttons and dialog | Asset tab cells                                 | Asset tab                                       |
| Set a code             | No                      | Scan into a code row                            | Scan into a code row, only the attribute's kind |
| Copy, download, remove | Yes                     | Remove by clearing the row                      | Remove by clearing the row; save to the gallery |
| Scan to find an asset  | No                      | Scan buttons, "Search by code", overflow menu   | Floating scan button and the "+" menus          |
| Camera scanner         | None                    | Its own view: QR, barcode or both, with a torch | ZXing: every type                               |
| Smart Tag              | No                      | Needs NFC and `nfc_enabled` on the asset menu   | Needs NFC turned on                             |
| Offline                | No                      | Yes, lookup on the phone                        | Yes, lookup on the phone                        |

## Screens

* [Code scanner](https://docs.snapfix.com/how-the-apps-work/screens/assets/code-scanner.md): the scanner, the NFC reader, the lookup and the found and not-found sheets.
* [Asset attributes](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-attributes.md): the code rows, with their scan and remove buttons.
* [Asset detail](https://docs.snapfix.com/how-the-apps-work/screens/assets/asset-detail.md): the code buttons and the code dialog on the web.
* [Asset register settings](https://docs.snapfix.com/how-the-apps-work/screens/assets/register-settings.md): the attributes that hold the codes.

## API and data

* [`POST /v1/app/assets/save-attributes`](https://docs.snapfix.com/engineering-reference/api/assets.md#post-v1appassetssave-attributes): the web's code removal, an empty value. The apps send code values with [`?action=save_pri_jobattribute`](https://docs.snapfix.com/engineering-reference/api/assets.md#post-actionsave_pri_jobattribute).
* The code attributes are attribute rules of type `qr`, `barcode` and `nfc`: [`POST /v1/app/asset-regs/{uuid}/attribute-rule`](https://docs.snapfix.com/engineering-reference/api/assets.md#post-v1appasset-regsuuidattribute-rule) on the web, [`?action=save_pri_businessjobattributerule`](https://docs.snapfix.com/engineering-reference/api/assets.md#post-actionsave_pri_businessjobattributerule) in the apps.
* Tables: [`tPri_JobAttribute`](https://docs.snapfix.com/engineering-reference/db/tables/tpri_jobattribute.md) (the values) and [`tPri_BusinessJobAttributeRule`](https://docs.snapfix.com/engineering-reference/db/tables/tpri_businessjobattributerule.md) (the attributes, with their category, type, mandatory and unique flags).

## Depends on

* [Asset registers](https://docs.snapfix.com/product/features/assets/asset-registers.md): the attributes, the assets and who may see them.
* [Asset tasks](https://docs.snapfix.com/product/features/assets/asset-tasks.md) and [Task creation](https://docs.snapfix.com/product/features/tasks/task-creation.md): the task a scan starts.
* [Checklists](https://docs.snapfix.com/product/features/checklists/checklists.md): NFC checks on checklist items also read tags.
* [Subscriptions](https://docs.snapfix.com/product/features/billing/subscriptions.md): the plan feature `nfc_enabled` \[[ASK-23](https://github.com/snapfix/docs/blob/main/ASK.md#ask-23-should-plan-limits-be-enforced-on-the-web-and-the-server)].

## Edge cases

* **Offline:** scanning and the lookup work on the phone; values wait for the sync.
* **No camera or no permission:** iOS says "Scanning not supported" / "Your device does not support scanning"; Android asks for camera permission, then offers its settings ([Code scanner](https://docs.snapfix.com/how-the-apps-work/screens/assets/code-scanner.md#states)).
* **No NFC:** the Smart Tag path shows the NFC message and does not start; mandatory Smart Tags are skipped.
* **Several assets with one code:** iOS opens one of them.
* **Apostrophe in a code:** the iOS lookup finds nothing.
* **Archived asset or register:** the iOS lookup does not find it.
* **Several sites:** the iOS lookup searches the selected site only.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/product/features/assets/asset-codes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
