Model Actions¶
Model actions allow you to trigger a sequence of Action Framework actions that run automatically when model-level events occur. This means the actions don’t need to be tied to a button or intentionally activated by the end-user, but are activated “behind the scenes” when specific things happen on the page. Model actions are useful for creating simplified, automated workflows, even for complex processes.
Create a Model Action¶
- In the Elements pane, click the Models tab.
- Click the model name.
- Below the model name, click Actions.
- Click
- Set initiating events (and properties of those events) in the Initiating events tab.
- Add specific action framework sequences using the Actions tab.
Add to create a new model action. - Click Save.
Using Model Actions¶
The following are a couple examples where model actions create a streamlined user experience.
Update Roll-up Summaries [[]]¶
The situation¶
A Table component connected to on an object that collects sales opportunities. The table displays:
- the opportunity by name
- the account name
- the amount of the opportunity
- the close date for the opportunity
Each opportunity has a drawer with a table component where the end user can add products to an “ordered product” list, with fields for the price book ID, quantity of the product, sales price and total price. The total price is a UI-only field: {{UnitPrice}}*{{Quantity}}
This field updates in real time when changes are made to the quantity or the sales price.
The challenge¶
End user would like to see the amount on the opportunity table automatically update as products are added to the product list—without having to refresh the page.
The model action¶
Initiating action tab
- Initiating event: Row in Model updated
- When which fields are updated: The UI-only total price field
Action tab
- Action type: Query model
- Model: The model on the opportunity object.
- Query behavior: Standard - Completely Replace Data
Push Data from Ui-Only Fields to Database Fields [[]]¶
The situation¶
A Table component connected to on an object that collects sales opportunities. The table displays:
- the opportunity by name
- the account name
- the amount of the opportunity
- the close date for the opportunity
Each opportunity has a drawer with a table component connected to a products object. Here, the end user can add products to an “ordered product” list. This list includes the following fields:
- price book ID
- quantity of the product
- sales price
- discount (a UI-only field:
{{DiscountUI}}
) - total price (a UI-only field:
{{UnitPrice}}*{{Quantity}}*((100-{{DiscountUi}})/100)
). - Current price
The challenge¶
Often builders employ UI-Only fields so that end users can see (in real time) how their changes will affect data, for example, how changes in the UI-Only discount field shift the (also UI-Only) total price. But, if the discount is confirmed, then that UI-only total price needs to be pushed back to the actual discount field in the database (not the UI-Only discount field used for the onscreen calculation) when the user clicks Save. This ensures that the agreed-upon discount will be saved to the external system.
The model action¶
Initiating action tab
- Initiating event: Row in Model updated
- When which fields are updated: The UI-only discount field
Action tab
- Action type: Update a field on row(s)
- Model: The model on the products object
- Field: The discount field in the products object
- Value:
{{DiscountUi}}
Properties¶
Initiating events tab [[]]¶
Initiating events are changes to Skuid models that begin a sequence of Action Framework actions. Click Add to create a new model action, then select the initiating event for it:
Initiating events
- Model saved: When the model is saved, whether as the result of user input or an Action Framework action.
- Model requeried: When the model is queried, which can occur on page load or by an Action Framework action.
- Model cancelled: When changes to the model (as the result of user input or an Action Framework action) are cancelled.
- New row created in model: When a new data row is added to the model, as the result of user input or an Action Framework action.
- Row in model updated: When one or more fields are updated as the result of user input or an Action Framework trigger. You may select whether this initiating event applies to specific fields or to all fields in the model.
- Row in model marked for deletion: Marks the selected row on the model for deletion as the result of user input or an Action Framework trigger.
- Row in model un-marked for deletion: Unmarks the row on the model selected for deletion as the result of user input or an Action Framework trigger.
Changes to model conditions can also be selected as initiating events.
Model condition changed: If the value of a model’s condition changes (even in the background, unactivated).
Model condition activated: When a model’s condition is activated, whether or not the model affected by it has been requeried.
Model condition deactivated: When a model’s condition is deactivated, whether or not the model affected by it has been requeried.
Model condition reset: When the condition’s value is reset. This can only be done through Skuid’s JavaScript API.
- When which conditions are changed? For each of the previous condition-related events, select trigger to begin the sequence. Options include:
- Any filterable condition
- One or more named conditions.
- When which conditions are changed? For each of the previous condition-related events, select trigger to begin the sequence. Options include:
Actions tab [[]]¶
Select the model actions:
- Actions:
- Add action: Click to add actions and set them.
- Convert to action sequence: Click
- Display Name: Give the sequence a memorable name.
- Description: Describe the goal or purpose of the sequence.
to establish an action sequence.
- Action type: Use the Action Framework to create actions.