How to refresh current summary view

Hi team,

In my users collection, I have a summary view like this one:
image

Under Card, we can see the Smart field reference of the cards collection (hasOne association from users to cards collection). This smart field is built in part from the card’s status.

The “Get card status update” action is requesting a remote status in order to update the status field of the user’s card.

How to refresh the current user details section in the called action.

The end of the route called is currently containing:

    return res.send({
      success: `Operation completed. ${message}`,
    });

I tried this:

    return res.send({
      success: `Operation completed. ${message}`,
      refresh: { relationships: ['user_details'] },
    });

But it did not work as user_details is not a relationship but the collection itself.
Is there a simple way to do it please?

Thanks.

My current setup:

    "database_type": "postgres",
    "liana": "forest-express-sequelize",
    "liana_version": "6.3.11",
    "engine": "nodejs",
    "engine_version": "12.13.1",
    "framework": "express",
    "framework_version": "^4.17.1",
    "orm_version": "4.44.0"

Hello @Louis-Marie !
Please tell me if I understand your problem: You have a smart-field composed from data from both your database and a remote API call, and when you click on your smart action you want the field to be refreshed ?

If that’s the case can you try with

  return res.send({
      success: `Operation completed. ${message}`,
      refresh: { relationships: ['cards'] },
    });

Hi @Nicolas_Sailly

You’ve got my problem.

Unfortunately, your solution does not work.
The card smart field (used as reference) is still not refreshed at the end of my action.

Any other idea?

Thanks.

Hi @Louis-Marie,

Could you try replacing the 'cards' relationship in the solution Nicolas gave you by 'card'.

If ever that’s not working, could you answer those questions so I can try to reproduce your issue on my end:

  • Is cards a basic collection or a smart collection?
  • You said that that card was a smart field, could you share with me the definition of this smart action?

I hope this will help you!

Hi @lamatt_v,

Could you try replacing the 'cards' relationship in the solution Nicolas gave you by 'card' .

I tried, but nothing changed.

Is cards a basic collection or a smart collection?

It is a basic one (a native SQL table)

You said that that card was a smart field, could you share with me the definition of this smart action?

Please find below the main information regarding users, cards and things related to that issue:

db.users.hasOne(db.cards);
db.cards.belongsTo(db.users, { as: 'user', foreignKey: 'user_id' });

Liana.collection('cards', {
  fields: [
    // ... some other smart fields ...
    {
      field: 'CHID_and_status', // used as Reference
      type: 'String',
      get: (card) => {
        if (card.remote_id && card.status === 'Deposit Only') {
            return `${card.remote_id} / 🔥 Locked`;
        } else if (card.remote_id && card.status) {
            return `${card.remote_id} / ${card.status}`;
        } else {
            return null;
        }
      },
    }, 
  ],
}

Liana.collection('users', {
  actions: [
    // ... many other actions ...
    { name: 'Get card status update',
      type: 'bulk',
      endpoint: 'forest/actions/users/get_card_status_update',
    }, 
  ],
}

Basically, the smart action itself requests the remote status card, and updates the local status of the native cards table. The update is made without any problem. When I reopen the users record, the new status is correctly displayed.

Thanks for your help.

I’ve eventually been able to understand and reproduce your issue.

Reference fields are designed to change the displayed content of a link to another resource. Unfortunately when performing a refresh after a smart action, only the updated id is tracked to update the link correctly (if you had change the related card itself and not its status, the link would have been updated correctly. But not the link content unless it’s the id itself)

As this behavior is not something previously handled by ForestAdmin and then broken I cannot make a bug report out of it. But I’ll flag it as a feature request from you and hand it over to our product team.

Best regards

Hi @lamatt_v

Thank you for your answer.

I understand your point of view, linked to technical constraints.

However, for a user’s point of view, he has a screen that shows a value (the smart field reference), and the updated value is not reflected after execution of the action. IT IS considered as a bug by the final user.

In this context, it cannot be just considered as a new feature request.
From my point of view, I would consider this as a misconception issue.

But, of course, things has to be improved little by little.
I would just kindly ask you to consider this as an issue not an improvement request.

Many thanks for your help.
Best regards

Hi @Louis-Marie,

We found the issue and created an issue for that bug.
You can keep track of the status here:

Hey @Louis-Marie ,

We released the fix this morning :wink:

1 Like

Hi @vince

That works as expected. Perfect.

Thank you very much!
Best regards

2 Likes