Define a View

A view is composed of components that display in a Slack surface: a home tab, message, or modal. Define a view in a .view file, which is YAML that describes the components that make up the view.

In a Slack runtime environment, a view translates to blocks. In your SFDX project, a view lives in the force-app/main/default/viewdefinitions folder. For more information, see the ViewDefinition Tooling API object.

Components in a view can handle events such as a button click. See Interactive Components. You can also bind data to a view using expressions and data providers.

Views are not cached. If your view fails to render, check your view definition and YAML indentation.

KeyTypeDescription
descriptionStringA description of this view. Not used in code.
schemaObjectThe input properties for this view.
schema.propertiesObjectA map of property names to their schema.
schema.properties.typeStringThe type of the property value. One of these values: string, boolean, number, list, map, or null.
schema.properties.requiredBooleanSpecifies whether the property is required. If true, defaultValue is ignored.
schema.properties.defaultValueStringThe default value to use if one isn't provided and required is false. Must be a literal value.
dataprovidersObjectThe data sources for this view. A map of data provider keys to data providers.
dataproviders.definitionStringRequired. The name of the data provider in the format apex__MyClassName.getMyMethodName or apex__MyNamespace.MyClassName.getMyMethodName.
dataproviders.propertiesObjectThe input properties for this data provider. A map of property names to either literal values or string expressions.
componentsArrayRequired. The components that make up this view.
components.definitionStringRequired. The name of the component definition.
components.nameString, ExpressionThe name to uniquely identify the component within the view.
components.visibilityBoolean, ExpressionIndicates whether the component is shown or hidden. If this property isn't present or it evaluates to true, the component is shown. Otherwise, the component is hidden.
components.propertiesObjectThe properties of this component. A map of property names to literal values or expressions.
components.componentsArrayThe child components of this component.
regionsArrayThe regions for this view component. Not currently supported.

Some components can handle an event like onclick or onchange, which is also configured in the view definition. See the Component Reference.

Use these examples to build your own views.

This view definition displays a message in a modal. The modal component contains a section component. The view has a title and message property, which is bound to the modal's title and section's text property each.

This view definition displays a modal for creating a record. The modal contains a section component with an actions component, which has a button to create the record. When clicked, the button calls the createOpportunity Apex class.

This view definition creates an opportunity record when the submit button is clicked. When clicked, the button calls the submitOpportunity Apex class. The modal contains input fields with placeholders, including a select component with a list of options.