Smart/flattened fields with references are not resolved

Feature(s) impacted

  • Smart fields
  • Flattened fields
  • CSV export

Observed behavior

I have a collection with smart fields and flattened fields that reference other items, in the list view, the link appears as the raw ID, and not the reference field I’ve set up in the child collection.

In the CSV export (the default of Forest), the smart field is a JSON.stringigy'd ObjectID that looks like this: {"type": "Bufffer", "data": [12, 67, 48, 32 ...]}. The flattened fields are represented by the JSON.stringify'd parent, so say I have the following document:

{
  rootField1: 'some value'
  rootField2: '1234909908093482094' <- reference to another document
  objectField1: {
    subField1: '8983980723498249fdsff0' <- reference to other document
    subField2: '8983980723498249fdsff1' <- reference to other document
  }
}

With the following Mongoose model:

{
  rootField1: String,
  rootField2: { type: Schema.Types.ObjectId, ref: 'User' },
  objectField1: {
    subField1: { type: Schema.Types.ObjectId, ref: 'Note' },
    subField2: { type: Schema.Types.ObjectId, ref: 'Product' },
  }
}

rootField2 will be properly handled, so let’s say the target document is a User and the reference field on this collection (Users) is the email, it will appear as the email in the list and it will also be properly serialized in the CSV.

But in my table I will see the column objectField1 -> subfield1 as 8983980723498249fdsff0.

In my export, the objectField1 -> subfield1 value will be "{"subfFeld1": "8983980723498249fdsff0", "subField2": "8983980723498249fdsff1"}" where I’m expecting a string with the referenced field value within the target collection.

The same behavior occurs for a smart field, I will see the raw ID in the list, and a JSON.stringify'd ObjectID in the CSV export

List view:


Here the flatten fields are Raw IDs but the created by field was properly referenced.

CSV:


Broken because the JSON has separators

Sorry for the lack of images but it seems to be broken, I get an error telling me to try again later.
The image upload does not work on Firefox FYI

Expected behavior

What I’m expecting is to see the referenced document’s reference field value and not the raw ID in the table or anyJSON.stringify’d object in my CSV export.

This is a critical feature I need to use, we are paying a quite expensive plan and in the end I always have to reimplement all the routes to simply display/export things properly. But obviously I’m loosing all the filtering features and other things that actually make Forest admin actually valuable…

Context

Current version of forest-express-mongoose is 8.4.4
Current version of mongoose is 5.13.13
The problem occurs on all my environments.

Hello @jganichot ,

Sorry to hear that! I am trying to reproduce your error and will get to you as soon as possible

Hi @mian

Thanks! I updated my original post with images, the upload is just not working on Firefox.