User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
  
English
日本語
action

Usage

view: view_name {
  measure: field_name {
    action: {
      label: "Label to Appear in Action Menu"
      url: "https://example.com/posts"
      icon_url: "https://looker.com/favicon.ico"
      form_url: "https://example.com/ping/{{ value }}/form.json"
      user_attribute_param: {
        user_attribute: user_attribute_name
        name: "name_for_json_payload"
      }
      param: {
        name: "some_auth_code"
        value: "abc123456"
      }
      form_param: {
        name: "title"
        type: select | string | textarea
        label: "desired label name"
        description: "description text"
        required: yes | no
        default: "value string"
        option: {
          name: "name string"
          value: "value string"
        }
      }
    }
  }
}

Hierarchy

action

Possible Field Types

Dimension, Measure

Default Value

None

Accepts

Various parameters

Special Rules

  • The form_url’s URL must be accessible to the Looker server and use HTTPS with a valid certificate.
  • The icon_url’s URL must be accessible to the user’s browser.

Definition

The action parameter creates a data action that lets users perform tasks in other tools, directly from Looker. For example, the action can cause an email to be sent, set values in other applications, or anything else that you configure a receiving server to do. The receiving server must be able to accept a JSON POST.

You can define an action for a dimension or measure field. Then the action is accessed by clicking its field when on an Explore page, Look, or dashboard.

When defining an action, you specify the desired behavior using the following parameters:

Parameter Description
label A string specifying the name of the action as it will appear to users in the Action menu
url A string specifying the URL to process the action
icon_url A string specifying a URL that contains an image file to make it easier for users to understand, at a glance, where this link will direct them
form_url A string specifying a URL that will return a form to present to users; the form must be presented in a JSON format as described below
user_attribute_param Passes a user attribute to the action server
param Passes a value to the action server
form_param Adds a form input that will be displayed for this action

The icon_url URL must be accessible to the user’s browser.

The form_url URL must be accessible to the Looker server and use HTTPS with a valid certificate. It must return JSON of the form:

Passing User Attributes to the Action Server Using user_attribute_param

You can send user attributes to the action server by using the user_attribute_param parameter. Within each user_attribute_param you’ll specify the following sub-parameters:

Parameter Type Description
user_attribute Looker ID The name of the user attribute in Looker
name String The name of the attribute as you want it to appear in the JSON payload

Passing Values to the Action Server Using param

You can send arbitrary data in your JSON payload by using the param parameter. Within each param you’ll specify the following sub-parameters:

Parameter Type Description
name String Name of a parameter to pass to the action server
value String Value of a parameter to pass to the action server

Specifying Form Behavior Using form_url or form_param

You can create a form for Looker users to interact with, and then submit their form input in your JSON payload. If you display a form, it will appear as an overlay on the page (Explore, Look, or Dashboard) where the action was triggered. This can be done with either the form_url or form_param parameter.

If you want your Action Server to define the form layout, use the form_url parameter. The form_url should contain a URL that returns a JSON representation of the form as described below.

If you want to define the form layout directly in the LookML, use the form_param parameter.

Form Options

In both cases the possible options that you may use to define the form are:

Option Type Description
name String The name of the value as it will appear in your JSON payload
type Input Type The type of form field that will be displayed to the user:
select - displays a drop-down list
string - displays a single line input field
textarea - displays a multi-line text input box
label String The label for the input as it will appear to users
description String A description for the field that will appear to users, if desired
required Boolean Specifies whether the form option must be provided by the user before the form is submitted
default String The starting value of the form field, if any
option String If you choose a type of select, define the select options here

If you set the type to select, you then specify items in the drop-down list using option. Each option includes the following details:

Option Type Description
name String Name of the form value as it will appear in your JSON payload
label String The label for the option as it will appear to users (optional)

Examples

If you use the form_url parameter all of the options must be returned in a JSON object. For example:

[
  {
    "name": "title",
    "type": "select",
    "label": "desired label name",
    "description": "description text",
    "required": true,
    "default": "value string",
    "options": [
      {
        "name": "name string"
        "value": "value string"
      },
      {
        "name": "name string"
        "value": "value string"
      }
    ]
  },
  {
    "name": "title",
    "type": "textarea",
    "label": "desired label name",
    "description": "description text",
    "required": true,
    "default": "value string",
  }
]

If you use the form_param parameter the options are used as LookML parameters. For example:

form_param: {
  name: "title"
  type: select
  label: "desired label name"
  description: "description text"
  required: yes
  default: "value string"
  option: {
    name: "name string"
    value: "value string"
  }
}

Things to Know

Consider Using the Action Hub Instead

The action parameter is a good choice if you already have an Action Server, or if you want to implement a use case with limited re-usability. However, if you are going to create an Action Server anyway, you may want to consider Looker’s Action Hub instead.

In addition to the existing Action Hub integrations, you may also create your own Action Hub integration by following these instructions.

Top