Displaying Sales Order Reference Files in FSM Mobile

A separate resource can show reference documents from sales orders linked to the current case. The files resource handles job uploads. This pattern searches for native file IDs attached to those orders and supplies download mappings. It is read-only and doesn't require the supplied Files write operations.

Merge this custom resource under "routes/mobile", then add sofiles to each applicable event rule's resource list. For instructions on resource selection, see Selecting Resources. The nested sales order search uses custbody_nx_case. event.supportcase must supply the current case's internal ID. A missing case resolves to the nonmatching ID 0.

          {
  "routes/mobile": {
    "sofiles": {
      "label": "Sales Order Files",
      "icon": "paperclip",
      "readonly": true,
      "element": {
        "name": {
          "type": "text",
          "title": true,
          "column": 1,
          "hidden": true
        },
        "document": {
          "type": "file",
          "label": "Download",
          "readonly": true
        },
        "description": {
          "type": "textarea",
          "column": 2
        },
        "size": {
          "type": "number",
          "unit": "byte",
          "column": 3
        }
      },
      "article": {
        "record": "file",
        "filters": [
          "internalid",
          "anyof",
          {
            "array": true,
            "default": "@NONE@",
            "salesorders": {
              "record": "salesorder",
              "filters": [
                "custbody_nx_case",
                "anyof",
                "${ event.supportcase || 0 }"
              ],
              "map": "formulatext:{file.internalid}"
            }
          }
        ],
        "map": {
          "name": "name",
          "document": {
            "id": "internalid",
            "url": "formulatext:'mobile/file/'||{internalid}"
          },
          "description": "formulatext:regexp_replace({description}, '[\r\n]*{[^}]*}$', '')",
          "size": "formulanumeric:{documentsize}*1024|"
        }
      }
    }
  }
} 

        

The outer search retrieves only the native file IDs returned by the linked sales orders' attachment search. It doesn't select all files in those orders' folders. readonly: true removes create, edit, and delete actions in FSM Mobile. Making this independently defined resource editable would require an established write implementation. Matching the Files record type and elements doesn't supply its specialized operations.

Additional Information

Related Topics

General Notices