Referenced Fields Inconsistency

Feature(s) impacted

Reference Fields

Observed behavior

My reference fields are not showing the input when called from a Smart Action that is not also on the same model (I am calling it from a related model as well).

Expected behavior

I would expect to see an input for my Referenced fields; regardless of where I call a Smart Action that has a Referenced Field. As long as the correct model is passed, then the behavior should be the same.

Failure Logs

If I call the action on the same model that it is declared, then it works correctly: Loads the related data into the Referenced Field. Below is an example of when it works:

If I call the same action from a different view in Forest that is not the same model, then I will see this when pulling up the Smart Action:
CleanShot 2022-03-29 at 23.25.47@2x

The code for the Smart Action is the same:

{
  field: 'BeaconID',
  reference: 'Beacon.ID',
  required: true,
  type: 'Number'
},
{
  field: 'UserID',
  reference: 'User.ID',
  required: true,
  type: 'Number'
},

In the load hook, a call is made to fetch the Beacon, and load in its ID like so:

hooks: {
  load: async ({ fields, record }) => {
    const {
      talentQueueId,
      id,
      userId
    } = record.dataValues;

    const fetchedBeacon = await Beacon.findOne({ where: { talentQueueId } });
    const { id: beaconId } = fetchedBeacon?.dataValues || {};

    fields.BeaconID.value = beaconId;
    fields.UserID.value = userId;

    return fields;
}

The only difference is how I call one vs the other. For the one that is on the same model, I simply use a button:

<Button::BetaButton
  @type="info"
  @text="📞 Outreach"
  @action={{fn
    this.triggerSmartAction
    @collection
    "Create Suggested Stub State Action"
    record
  }}
/>

On the other, I also use a button, but I call my own trigger because I need to make sure I reload the current queue(recordset):

this.triggerSmartAction(this.suggestedTalentStubModel, 'Create Suggested Stub State Action', suggestedTalentStub, this.refreshCurrentQueue.bind(this), undefined, true);

Context

Everything else functions and works as expected, but the referenced fields do not get pre-populated as they should.

Any thoughts or pointers? Thanks!

"meta": {
    "liana": "forest-express-sequelize",
    "liana_version": "7.12.3",
    "stack": {
      "database_type": "postgres",
      "engine": "nodejs",
      "engine_version": "16.14.0",
      "orm_version": "6.11.0"
    }
  }

Hi @David_Panzarella :wave: have you got any errors log on your browser console?
In order to understand what happens. Can you try to see the difference between the calls of the action load hook, in your browser network tab.

http://yourhost/forest/actions/actionname/hooks/load

Hi @Arnaud_Moncel,

Yes, action routes are exactly the same, as are the payloads and fields.
Request URL:

http://localhost:3310/forest/actions/suggested-talent-stub-state-actions/hooks/load?timezone=America%2FLos_Angeles

Payload looks like:

And this is for both cases. Again though, it works fine when on SuggestedTalentStub, but not via any other model.

When it fail:
Have you got any errors log on your browser console?
What is the result of the load request? Are the data seem good?

I get the following errors one either one:

But I think I read somewhere that values is deprecated from smartActionTrigger anyways so :man_shrugging: .

But this is exactly the same for both:

This is why this is so confusing. As you can see both fields have the correct value ID, but one isn’t pulling in on the load. Could it simply be an async issue? Eg. one is waiting, while the other is not?

But I think I read somewhere that values is deprecated

That’s right! Don’t worry about that.

If the /hook/load is called is the most important thing.

I have a question, you say

If I call the same action from a different view in Forest that is not the same model, then I will see this when pulling up the Smart Action:

On the falling way, Have you load by any way the Beacon record with id 1?
I supposed the reference field on the Beacon collection is not the id field but another field.
Maybe the problem is here.

Let me know :pray:

Unfortunately, that’s just a different record. The data is correct but isn’t loading regardless of which ID is chosen. Any way we can schedule a screen share?

@Arnaud_Moncel any updates on this? Can we schedule a time to screen share?

@Arnaud_Moncel any updates here?

Still waiting here @Arnaud_Moncel. Can anyone from @dev_support offer a solution here?

Hello @David_Panzarella :wave:

By looking at your topic, I’m struggling to understand why the action is working on a case, but not on another.

To have a better idea on what you are doing, would you mind posting a quick screen recording of the two cases:

  • The case where the two fields are correctly filled in
  • The case where the two fields are not correctly filled in

I just would like to see how you navigate through the app.

Also, I’m interested in the fields value you return in your script. Would you mind posting the value of this attribute for both valid and failing cases please ?

Thanks in advance.

Steve.

Hi @Steve_Bunlon,

Thanks for the reply and sorry for the delay.

Unfortunately, I’ll need to get some dev data set up to show you the example via a Loom. If possible, I’m happy to set up a screen share session with you to show what the issue looks like in production. Let me know if that’s an option, and if not, I will try to post a video to emulate the behavior.