Web Services: Ability to Specify a Comment for an Attached File

In MYOB Acumatica 2024.2.1, a developer can use the REST API to specify a comment for a file that is attached to a record. A user can see this comment in the Comment column of the Files dialog box, which is shown in the following screenshot. (The dialog box opens if the user clicks Files in the title bar of an MYOB Acumatica form that is open for a record with at least one attached file.)

Figure 1. The Comment column


Adding a Comment

To add a comment for a file that is attached to a record, the developer needs to send the PUT request to the URL for attaching a file to a particular record and include the following in the request:

  • The PX-CbFileComment header with the comment text
  • The file in the request body

For details on this request, see Attach a File to a Record. An example of the request is shown in the following code.

PUT /a0f8594a-7de2-e811-b816-00155d408001/T2MCRO.jpg HTTP/1.1
Host: [<MYOB Acumatica instance URL>]/entity/Default/24.200.001/files/
    PX.Objects.IN.InventoryItemMaint/Item
Accept: application/json
Content-Type: application/octet-stream
PX-CbFileComment: Test comment

"<file contents here>"
The following usage details apply to comments that the developer adds to a file in this way:
  • If a new version of the file is added without a comment, the Comment column in the Files dialog box becomes empty for the file.
  • If multiple PX-CbFileComment headers are specified in the request, the Comment column contains the comments from all headers. The comments are separated with a comma.
  • A comment for the file cannot exceed 500 characters.

Obtaining a Comment

If a developer obtains the list of files attached to a record, a comment for a file is returned in the comment field for the file item in the files array.

The following example request retrieves the list of files attached to the EJECTOR03 stock item.

GET /EJECTOR03?$select=InventoryID,files&$expand=files HTTP/1.1
Host: [<MYOB Acumatica instance URL>]/entity/Default/24.200.001/StockItem
Accept: application/json
Content-Type: application/json

The response body, shown below, includes the comment in the comment field.

{
  "id":"a0f8594a-7de2-e811-b816-00155d408001",
  "rowNumber":1,
  "note":
  {
    "value":""
  },
  "InventoryID":
  {
    "value":"EJECTOR03"
  },
  "custom":{},
  "_links":
  {
    "self":"...",
    "files:put":"..."
  },
  "files":
  [
    {
      "id":"8050623c-b31f-42a1-876a-13598c90fd29",
      "filename":"Stock Items (EJECTOR03   )\\T2MCRO.jpg",
      "href":"...",
      "comment":"Test comment"
    }
  ]
}

For details about retrieval of file comments, see Retrieve Comments for Attached Files.