Smart Action Forms without static fields, do not show up with the dynamic ones

Not sure if this is a feature request or a bug

Feature(s) impacted

Smart Actions with no fields that use load hooks.

Observed behavior

If a smart action with no initial fields is triggered then a form will not appear.

Expected behavior

I expect that if fields are added using load hooks, then a smart action form will still appear with the newly loaded fields.

Example code

As you can see in the example code you would start with an empty fields array, and we would ideally like to dynamically add fields to the smart action form. While we do appreciate that the form is skipped when there are no fields. I guess ideally the load hook should occur before determing whether the form should be skipped or not.

{
  name: "Smart Action",
  download: true,
  fields: [],
  hooks: {
    load: ({ fields, request }) => {
      const field: Liana.SmartActionLoadHookField = {
        field: `custom field name`,
        type: "String",
        position: 0,
        widget: "text area",
        value: `custom value`,
      };
      fields.push(field);

      return fields;
    },
    change: {},
  },
}

Context

  • Project name: Bridgement
  • Team name: Bridgement
  • Environment name: Production
  • Agent type & version: forest-express-sequelize: v8.4.10

Hello again @SoftwareBridgementKe :wave:

It is not a bug :thinking:.
This is at the moment, by design: if there are no static fields, then the action is immediately performed. I’ll push your request to our product team :memo:

In the meantime, you can add a “dummy” static field in your configuration to be discarded in the load hook.
By returning a new array either empty or populated with whatever your business logic is doing in there, you should be able to circumvent this limitation.

Tell me if any of this helps :slightly_smiling_face:

1 Like

@Romain_Coudour Yeah that’s what we’re currently doing as a work around. :+1:

The only downside with that fix is if you end up returning an empty fields array, the smart action form will still appear. Ideally we would want it so that if the load hook returns no fields, then the form is skipped.