Skip to content
Snippets Groups Projects
Unverified Commit 582f4608 authored by Jeff Bruemmer's avatar Jeff Bruemmer Committed by GitHub
Browse files

update action docs (#29120)

parent d012954f
No related branches found
No related tags found
No related merge requests found
......@@ -34,11 +34,11 @@ Basic actions include:
The update action will present people with a form with editable fields for each column in the primary source table.
When setting up an Update action on a dashboard, you can either prompt the person to fill in a value for each field, or have a field automatically filled in via parameters (such as values set in dashboard filters).
When setting up an Update action on a dashboard, you must pass an entity key (like an ID) to the action from a dashboard filter. For other values, you can either prompt the person to fill in a value for each field, or have a field automatically filled in via parameters (such as values set in dashboard filters).
### Delete
The Delete action will create a form that prompts people for an ID, and will delete the record (row) corresponding to that ID in the underlying table that backs the model.
The Delete action will create a form that prompts people for an entity key, and will delete the record (row) corresponding to that ID in the underlying table that backs the model.
### Create
......@@ -46,7 +46,11 @@ The Create action is the `INSERT INTO` action. The Create action will present a
## Basic actions on dashboards
When setting up actions on a dashboard, you can either prompt the person to fill in a value for each field, or have a field automatically filled in via parameters (such as values set in dashboard filters). See [Actions in dashboards](../dashboards/actions.md).
When setting up actions on a dashboard, you can either prompt the person to fill in a value for each field, or have a field automatically filled in via parameters (such as values set in dashboard filters).
The Update basic action requires you to pass a value for the entity key.
See [Actions in dashboards](../dashboards/actions.md).
## Archiving basic actions
......@@ -56,3 +60,4 @@ Because basic actions are made of magic, you cannot archive them. You can just t
- [Introduction to actions](./introduction.md)
- [Custom actions](./custom.md)
- [Actions in dashboards](../dashboards/actions.md)
......@@ -14,7 +14,7 @@ Write SQL to update records in your databases.
There are two ways to create a custom action:
1. Click the **+ New** > **Action**. When you save your action, you'll be prompted to associate that action with a model. (NOTE: the **Action** option will only show up in the **+ New** menu if you've first created, or have access to, a model in Metabase.)
1. Click the **+ New** > **Action**. When you save your action, you'll be prompted to associate that action with a model. (NOTE: the **Action** option will only show up in the **+ New** menu if you've first created, or have access to, a [model](../data-modeling/models.md) in Metabase.)
2. Via the model detail page: from a model, click on the **info** button in the upper right. In the upper right of the sidebar, click **Model detail** > **Actions** > **New action**.
## Custom action editor
......@@ -27,20 +27,25 @@ For example, you could write an action that would update the `plan` column for a
{% raw %}
UPDATE invoices
SET plan = {{ plan }}
[[, payment = {{ payment }}]]
WHERE id = {{ id }}
[[, payment = {{ payment }}]]
WHERE
id = {{ id }}
{% endraw %}
```
The above code will create a form that prompts people to input updated values for the (required) `plan` field and optionally the `payment` field for a given record specified by `ID`. The code in brackets `[[ ]]` makes the statement optional: the bracket-enclosed statement will only run if someone inserts a value in the payment field.
The above code will create a form that prompts people to input updated values for the (required) `plan` field and optionally the `payment` field for a given record specified by `ID`.
The code in brackets `[[ ]]` makes the statement optional: the bracket-enclosed statement will only run if someone inserts a value in the payment field. Note the comma that separates the statements is _inside_ the brackets.
![Example action form](./images/form.png)
## Field types for action variables
For each {% raw %}{{ variable }}{% endraw %} that you set in an action, you'll need to set the field type.
Each of these variable field types present different options.
Each of these variable field types present different options. Click on the gear icon to change options.
If you don't require a variable, you can optionally specify a default value for Metabase to use in cases where people don't fill out the field.
If you don't require a variable, you can optionally specify a default value for Metabase to use in cases where people don't fill out the field. In the SQL code, remember to enclose any optional variables and commas in brackets, like `{% raw %}[[, column = {{ optional_variable }}]] {% endraw %}`.
You can include placeholder text for all fields in the action form.
......@@ -91,3 +96,4 @@ If something goes wrong, Metabase will display the error message it received fro
- [Introduction to actions](./introduction.md)
- [Basic actions](./basic.md)
- [Actions in dashboards](../dashboards/actions.md)
docs/actions/images/dashboard-action.gif

395 KiB

docs/actions/images/dropdown.png

167 KiB | W: | H:

docs/actions/images/dropdown.png

249 KiB | W: | H:

docs/actions/images/dropdown.png
docs/actions/images/dropdown.png
docs/actions/images/dropdown.png
docs/actions/images/dropdown.png
  • 2-up
  • Swipe
  • Onion skin
docs/actions/images/form.png

51.7 KiB

......@@ -4,6 +4,8 @@ title: Actions overview
# Actions overview
![An action updating a plan on a dashboard](./images/dashboard-action.gif)
Actions let you write parameterized SQL that can then be attached to buttons, clicks, or even added on the page as form elements.
## [Introduction to actions ](./introduction.md)
......@@ -17,3 +19,7 @@ Metabase will create basic actions that auto-track a model's schema.
## [Custom actions](./custom.md)
Write SQL to create new actions.
## [Actions on dashboards](../dashboards/actions.md)
Add actions on dashboards as buttons that you can pass filter values to.
\ No newline at end of file
......@@ -32,11 +32,20 @@ You can select from a variety of handsome buttons:
## Connecting an action to a dashboard filter
Many types of actions rely on knowing the entity IDs for the model to determine which records to update or delete. You can add a filter to the dashboard to filter on ID, and wire up that filter to the action button.
For most actions, when people click on a button, they'll be prompted to input values in the fields defined by that action.
![Wiring up an action button to a dashboard filter](./images/filter-to-action-button.png)
If you also wire that filter up to the model cards on the dashboard, you can filter for individual records, view them in the model cards, and update them with action buttons with the ID already filled in:
Many types of actions rely on knowing the entity IDs for the model to determine which records to update or delete. To have people select the ID for the action, you'll need to:
1. Click on the pencil icon to edit the dashboard.
2. Add an action to the dashboard (if you haven't already).
2. [Add a filter](./filters.md) to a dashboard, wire it up to any cards that you want to, and click **Done** in the bottom of the sidebar.
3. Hover over the action button and click on the **gear** icon, and select **Change action**.
4. Click on the field's dropdown to select where the action should get it's value. Here you can select "Ask the user" or have it automatically populated by a dashboard filter. In this case, we'll select our "ID" filter.
![Wiring up an action button to a dashboard filter](./images/id-value.png)
If you also wire that filter up to a card with a model on the dashboard, you can filter for individual records in that model, view them in the model's card, and have the action buttons auto-populate the id.
![Button form](./images/button-form.png)
......@@ -44,4 +53,5 @@ If you also wire that filter up to the model cards on the dashboard, you can fil
## Further reading
- [Actions](../actions/start.md)
\ No newline at end of file
- [Actions](../actions/start.md)
docs/dashboards/images/filter-to-action-button.png

108 KiB

docs/dashboards/images/id-value.png

93.2 KiB

......@@ -30,7 +30,9 @@ You can click on any cell in the permissions table to change a group’s access
### Unrestricted access
Members of the group can create questions using the graphical query builder on data from all tables (within all namespaces/schemas, if your database uses those), including any tables that might get added to this database in the future. To grant a group the ability to write native/SQL questions, you must additionally set [Native query editing](#native-query-editing) to **Yes**.
Members of the group can create questions using the graphical query builder on data from all tables (within all namespaces/schemas, if your database uses those), including any tables that might get added to this database in the future.
To grant a group the ability to write native/SQL questions or create [actions](../actions/start.md), you must additionally set [Native query editing](#native-query-editing) to **Yes**.
### Granular access
......@@ -80,9 +82,14 @@ Sandboxed access to a table can restrict access to columns and rows of a table.
## Native query editing
Members of a group with Native query editing set to Yes can write new SQL/native queries using the [native query editor](../questions/native-editor/writing-sql.md). This access level requires the group to additionally have Unrestricted data access for the database in question, since SQL queries can circumvent table-level permissions.
Members of a group with Native query editing set to "Yes" can:
- Write new SQL/native queries using the [native query editor](../questions/native-editor/writing-sql.md).
- Create and edit [custom actions](../actions/custom.md).
This access level requires the group to additionally have Unrestricted data access for the database in question, since SQL queries can circumvent table-level permissions.
People in a group without Native query editing permissions will still be able to view the results of questions created from SQL/native queries (though just the results, not the query), provided they 1) have collection access to the question, and 2) the question doesn't query a database that is [blocked](#block-access) for that group.
People in a group without Native query editing permissions will still be able to view the results of questions created from SQL/native queries (though just the results, not the query), or run an action, provided they 1) have collection access to the question or model, and 2) it doesn't query a database that is [blocked](#block-access) for that group.
## Download results
......@@ -117,7 +124,7 @@ On the database settings page, you can:
- [sync schemas](../databases/connecting.md#manually-syncing-tables-and-columns), and
- [scan field values](../databases/connecting.md#manually-scanning-column-values).
Note that only admins can delete database connections in your Metabase, so people with **Manage database** permissions won't see the **Remove database** button.
Note that only admins can delete database connections in your Metabase, so people with **Manage database** permissions won't see the **Remove database** button.
## Further reading
......
......@@ -20,7 +20,24 @@ You can also convert a question to a [model][model].
## Downloading Your Results
You can export the results of a question by clicking on the __Download arrow__ (a down arrow in a cloud) in the lower right of the screen. Results can be downloaded into .csv, .xlsx, or .json files. The maximum download size is 1 million rows. Exported .xlsx files preserve the formatting defined in the question: date and currency formats are kept throughout, as well as column ordering and visibility. Files names for the exported question will include a slug of the question title, so you can easily distinguish files when exporting multiple questions.
You can export the results of a question by clicking on the **Download arrow** (a down arrow in a cloud) in the lower right of the screen, or from a chart on a dashboard by clicking on the **...** in the upper right or a dashboard card.
Results can be downloaded as:
- .csv
- .xlsx
- .json
The maximum download size is 1 million rows. Exported .xlsx files preserve the formatting defined in the question: date and currency formats are kept throughout, as well as column ordering and visibility. Files names for the exported question will include a slug of the question title, so you can easily distinguish files when exporting multiple questions.
## Exporting charts as images
You can download most charts (excluding table and number charts) as images in .png format.
- From a question: click on the **download arrow** (a down arrow in a cloud in the bottom right) and select .png.
- From a dashboard card: click on the **...** in the upper right of the card and select .png.
You can't download the image of a dashboard, but you can set up a [dashboard subscription](../../dashboards/subscriptions.md).
## Editing your question
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment