Tips & Tricks: Managing Action Conditions

< Existing Method >
If you want the “Add” action for the “401_server” table to appear only in the “table_401_server_settings” view, you would set the condition as follows:

IN(CONTEXT("View"), LIST("table_401_server_settings"))

< New Method >
Step 1: Create two tables—action and actioncondition—to manage which views apply to specific actions:
action
- ID (key)
- name
- tableName
actioncondition
- ID (key)
- action (fk)
- views (EnumList)

Step 2: Register the view (“table_401_server_settings”) to be used for the “Add” action condition of the “401_server” table into the actioncondition table:

In other words, register “Add” in the action table and register “table_401_server_settings” in the child table, actioncondition.

Step 3: Set the condition for the “Add” action of the “401_server” table as follows:

IN(
  CONTEXT("View"), 
  ANY(SELECT(actioncondition[views], 
      AND(
        [action].[tableName]="401_server", 
        [action].[name]="Add"
      )
  ))
)

< Advantages >
It helps you view the conditions for key app actions at a glance.
It reduces errors that can occur with hard-coding.

What do you think of this approach?

Good to see you again @leinharte !

The following is an example I designed for another app. The logic is the same.

< step 1 >

The configuration table created separately is as follows:

action

  • ID (key)
  • name
  • tableName

actionviews

  • ID (key)
  • action (fk)
  • viewName (Enum)

actionistrues

  • ID (key)
  • action (fk)
  • type (Enum: CHECK_PERIOD_OPEN, CHECK_PERIOD_CLOSED, CHECK_IS_ADMIN)
  • isTrue( Virtual column, Yes/No)
    SWITCH([type],
    “CHECK_PERIOD_OPEN”, NOT(ANY(210_period_current[period_isClosed])),
    “CHECK_PERIOD_CLOSED”, ANY(210_period_current[period_isClosed]),
    “CHECK_IS_ADMIN”, USERROLE() = “Admin”,
    FALSE
    )

< step 2 >

Register setting values ​​in the action, actionviews, and actionistrues tables.

action

  • ID (key)
  • name => grouped_updateCfStatement_910_bot
  • tableName => 910_bot

actionviews

  • ID (key)
  • action (fk)
  • viewName (Enum) => detail_910_bot_updateCfStatement

actionistrues

  • ID (key)
  • action (fk)
  • type => CHECK_PERIOD_OPEN
  • isTrue( Virtual column, Yes/No)

< step 3 >

The action with the condition set is as follows.

Action name: grouped_updateCfStatement_910_bot

Behavior / Only if this condition is true:

AND(
IN(
CONTEXT(“View”),
SELECT(actionviews[viewName],
AND(
[action].[tableName]=“910_bot”,
[action].[name]=“grouped_updateCfStatement_910_bot”
)
)
),

NOT(IN(FALSE,
SELECT(actionistrues[isTrue],
AND(
[action].[tableName]=“910_bot”,
[action].[name]=“grouped_updateCfStatement_910_bot”
)
)
))
)

< summary >

Then, this action (grouped_updateCfStatement_910_bot) will only work (be visible) if the view name is detail_910_bot_updateCfStatement and NOT(ANY(210_period_current[period_isClosed])) is true.