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:
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"
}
}