Is it possible to create a smart action that can accept user's input?

Feature(s) impacted

Smart Action

Observed behavior

I notice that Smart Action does not accept any input.

Expected behavior

I expect I can create a Smart Action that would accept user’s input. How can I do that? Is there any other alternatives?

Failure Logs

Context

  • Project name: AdminConsole
  • Team name: LevaClinic
  • Environment name: Development
  • Agent type & version: …
  • Recent changes made on your end if any: …

Hello @winston0410,

It seems that you use forest-express-sequelize@8, so you’ll find here the documentation to create smart actions forms, allowing to use user input on actions.

Right! I have just figured out that I can use Smart Action Form too. I am now wondering if I can embed that form in the creation page of an entity?

Based on the doc, seems like Smart Action Form is only available like Smart Action after an Entity has been created?

Yes, smart actions are launched either globally or on specific instances. Both accept user input.

What are you trying to achieve?

We are trying to allow the user to create Entity D, when they are creating Entity A. Entity A and D are linked with a few join:

Table A(Entity A) <> Table B <> Table C <> Table D(Entity D)

Is it possible to customize the field in the page of pathname /data/<tablename>/index/record/<tablename>/create/details?

How many fields do they need to fill in?

If the default UI does not fit your needs, I suggest to create a global smart action with fields of both entities A and D, and code the creation based on these fields.

At the moment, it is possible to create related data as long with the main record by clicking “Create a new B” when creating a new “A”

Here is an example:

Capture d’écran 2022-08-26 à 08.36.17

@GuillaumeGautreau I see thanks! For the default UI, can I set a dynamic filter defined by Javascript/SQL? Or do I have to use Smart Action for that?

Hello @winston0410,

What do you mean by dynamic filter?

For example, I have an entity C, which has a schema like this:

CREATE TABLE IF NOT EXISTS C (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    # Omitting fields
    A_id UUID REFERENCES A(id),
    B_id UUID REFERENCES B(id)
);

and entity B has a schema like this

CREATE TABLE IF NOT EXISTS B (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    # Omitting fields
    A_id UUID REFERENCES A(id)
);

In Forest admin, I can create C from Related Data tab of A and B. When I use the default creation form in A, it will prefill the field of A with the id of the current entity, for example 1234-5678. Then I want to only show B with WHERE B.A_id = '1234-5678 in B’s dropdown. How can I achieve that?

I think you’ll need to use smart actions if you want this level of detail.