Displaying File and Image Fields in FSM Mobile

Merge only the intended changes. For guidance on the shared Editor, activation, merging, and Preview, see Updating and Validating FSM Configuration.

This topic includes the following sections:

Note:

The inspection examples use placeholder record and field IDs. Replace those IDs consistently with valid IDs from your account.

This example displays the Document field of existing inspections for the current CRM Task. The inspection record, Document field, and Task-link field must already exist. The IDs are illustrative placeholders. Add inspection_documents alongside the other required resource IDs in the matching CRM Task resource rule.

          {
  "routes/mobile": {
    "inspection_documents": {
      "label": "Inspection Documents",
      "readonly": true,
      "article": {
        "record": "customrecord_example_inspection",
        "parent": "custrecord_example_task",
        "map": {
          "document": {
            "id": "=custrecord_example_document|",
            "url": "formulatext:nvl2({custrecord_example_document},'mobile/file/'||{custrecord_example_document.id}, '')"
          }
        }
      },
      "element": {
        "document": {
          "type": "file",
          "label": "Inspection Document",
          "readonly": true
        }
      }
    }
  }
} 

        

When an inspection's Document field contains a file reference, the mapped ID and download address supply the download link. The ID mapping has no write destination, and the resource offers no create, edit, or delete actions. This view reads existing files. It requires record-search and file access but doesn't create or attach files. The editable inspection examples are separate resource definitions for capturing new content on the same illustrative record type. For the examples, see Configuring File and Image Uploads in FSM Mobile and Explicit File and Image Elements and Mappings.

Displaying the Item Image on an Asset

The supplied Asset resource displays the related Item's image as a read-only value. It prefers the Item's stored display thumbnail and falls back to its stored display image. This standard fragment shows the image definition and mapping. The Asset selection, other elements, and other mappings remain inherited.

            {
  "routes/mobile": {
    "asset": {
      "element": {
        "image": {
          "type": "image",
          "readonly": true
        }
      },
      "article": {
        "map": {
          "image": {
            "id": "=formulatext:nvl({custrecord_nx_asset_item.storedisplaythumbnail.id}, {custrecord_nx_asset_item.storedisplayimage.id})",
            "url": "formulatext:'mobile/file/'||nvl({custrecord_nx_asset_item.storedisplaythumbnail.id}, {custrecord_nx_asset_item.storedisplayimage.id})"
          }
        }
      }
    }
  }
} 

          

The Asset resource displays an Item image. The displayed image is not a writable image field on the Asset. Removing readonly from this element doesn't provide an Item or Asset image write destination.

Displaying File and Image Values Without Editing

To make the inspection resource view-only, merge the following fragment. For the resource definition, see Explicit File and Image Elements and Mappings. The fragment removes resource actions and both field write destinations. It also changes both inputs to read-only links. The mappings for the download address, record selection, and parent context remain inherited.

            {
  "routes/mobile": {
    "inspection": {
      "readonly": true,
      "article": {
        "map": {
          "document": {
            "id": "=custrecord_example_document|"
          },
          "photo": {
            "id": "=custrecord_example_image|"
          }
        }
      },
      "element": {
        "document": {
          "readonly": true
        },
        "photo": {
          "readonly": true
        }
      }
    }
  }
} 

          

To make only one field view-only, apply its element readonly and read-only ID mapping. Omit resource-level readonly so you can edit other inspection data. A value supplied by a search or expression must still have the File or Image object shape. For a search supplying one value, return the single mapped object rather than an array. For more information, see Selecting One Search Result. Don't construct upload data from a file name or bare ID.

Additional Information

Related Topics

General Notices