Record.attribute is null in smart view

Feature(s) impacted

Smart Views

Observed behavior

All attributes of the record which are of type “belongTo” are null, even though in the database they are not. For instance, each record of type User has a status, which is a belongsTo relationship to another table Status. when record.status is called in the template, it is null, also record.statusId is undefined. Also, we made sure that the isLoaded and is not isLoading. This only happens in one specific smart view and other smart views from different models work just fine.

Expected behavior

We expect to get the value of record.status upon calling it.

Failure Logs

Context

  • Project name: Ourboro
  • Team name: Approval Team
  • Environment name: ourboro-development
  • Agent type & version: …
  • Recent changes made on your end if any: …

Hello @morekaccino :wave: and welcome to our community

Let’s find the origin of this issue, shall we? :mag: :thinking: :hammer:

  • How do you fetch this record in your Smart View (code-wise)?
  • Are you able to find the call made in your Network tab? In the returned payload, is there the data you are expecting?
  • Is this a new model or something you set up a while ago?

Hello @anon37903635 , Thank you for your response.

this is how I query the item:

    const params = {
      filters: JSON.stringify({
        field: 'id',
        operator: 'equal',
        value: id,
      }),
      'page[number]': 1,
      'page[size]': 1,
    };
    this.currentCustomer = await this.store.query('forest-profiles-user', params).then(function(users) {
      return users.get('firstObject');
    });

It works, and all the non-relational attributes are coming through with the correct value.

I am able to find the call made in my Network tab. In the preview mode, I have attributes and relationships objects. I get all the non-relational attributes in the attributes object. What I’m looking for is not in the attributes object. Also, in the relationship object I don’t see the table for user status.

This is a model that we’ve been using for a long time.

Thank you,

HI @morekaccino :wave: what I can see you must declare the wanted fields in your params object when you request profiles-user.
Without doing this your agent fallback with all the “primitive fields”
For exemple,

const params = {
  'fields[profilesUser]': 'userStatus,anotherBelongsToField,anotherClassicField',
  'fields[userStatus]': 'aFieldCommingFromUserStatus',
  ...
};

Let me know if that help. :pray:

1 Like

Thank you so much! that worked.

1 Like

@Arnaud_Moncel
is there any way I can add those fields to the predefined variable “records”?

Unfortunately not, when we request the datas, we use the same request as table view.
It means we do not request for belongs datas, except reference field of referenced table, as we can’t display more than one information on a table view column.
That’s why you must do the request by yourself.
Let me know if that clear :pray: