Smart relationship field shows id instead of name (not populated)

Feature(s) impacted

smart field not populated correctly

Observed behavior

the desired referenced field is not being populated

Expected behavior

relationship field to show name of document

Failure Logs

no failure logs

Context

  • Project name: WescoverContentAdmin
  • Team name: Content Admin
  • Environment name: Development | nimrodmaltz
  • Agent type & version: “forest-express-mongoose”: “8.7.6”
  • Recent changes made on your end if any: added smart relationship

hello again,

we’ve seen this type of behavior before: Referenced field shows id (not populated) after migration to v8

ive created a smart belongs to relationship between two collections, it works fine, when clicked, the desired document is fetched.
but when looking at the field in the details tab or collection tab, the field reads as an id and it should read as document name as setted in the layout editor collection settings.
furthermore, when the target collection is cached (clicked once): the names appear.
so i’m guessing its not populated to begin with.

thanks in advance,
nimrod

Hey @nmz

Do you mind sharing the smart relationship definition as well as the HTTP request sent by the frontend to retrieve this data? (As DM if you consider this to be private)

Thanks in advance.

After getting the info, it seems like the issue was related to the smart field not returning the required element of the record (Here, _id and the reference field name) →

The previous code looked something like this

field: 'MyField',
type: 'String',
get: async () => {
     const record = await getRecord();
     return record._id
}

Whereas the code required to make reference field work would look like

field: 'MyField',
type: 'String',
get: async () => {
     const record = await getRecord();
     return record;
}

Seems like our documentation does not cover this case, so we’ll update it accordingly.
I’ll mark the thread as resolved :+1:

Thanks for reporting this :pray: