App Builder app Custom Configuration
Developers of distributable App Builder apps can define configuration options for users to set at deploy time.
Defining custom configuration options
Custom configuration can be defined via the configSchema
property.
app.config.yaml
Copied to your clipboard1application:2 <application config>3extensions:4 <extension configs>5configSchema: # This is a top-level property and is global to the app and all extensions6 title: 'the title'7 description: 'the description'8 properties:9 - title: 'Slack Webhook'10 type: 'string'11 description: 'Please provide the webhook used by this application. Configure in slack.com'12 envKey: 'SLACK_WEBHOOK'
Usage
The envKey
property of a custom configuration option maps to the environment variable name in the app.
Runtime action
To use custom configuration in a Runtime action, map the envKey
value for the desired variable to the inputs of the Runtime action, then access values via params.<envKey>
in the action code.
Example
app.config.yaml
Copied to your clipboard1configSchema:2 title: 'the title'3 description: 'the description'4 properties:5 - title: 'enable caching'6 type: 'boolean'7 envKey: 'IS_CACHING_ENABLED' <--- Environment variable name8application:9 actions: actions10 web: web-src11 runtimeManifest:12 packages:13 dx-excshell-1:14 license: Apache-2.015 actions:16 generic:17 function: actions/generic/index.js18 web: 'yes'19 runtime: nodejs:1620 inputs:21 LOG_LEVEL: debug22 IS_CACHING_ENABLED: $IS_CACHING_ENABLED <--- Mapped environment variable23 annotations:24 require-adobe-auth: true25 final: true26 code-download: true
Action code
Copied to your clipboard1async function main (params) {2 if (params.IS_CACHING_ENABLED) {3 enableCache()4 }5}67exports.main = main
Web application
To use custom configuration in the web application, values can be accessed directly via process.env.<envKey>
.
Example
app.config.yaml
Copied to your clipboard1configSchema:2 title: 'Configurable Web App'3 description: 'Web application that can be configured.'4 properties:5 - title: 'Frontend background color'6 type: string7 description: 'Please provide the background color for your frontend'8 enum:9 - blue-40010 - celery-40011 - indigo-40012 envKey: FRONTEND_BACKGROUND_COLOR <--- Environment variable name13application:14 web: web-src
Component.js
Copied to your clipboard<View backgroundColor={process.env.FRONTEND_BACKGROUND_COLOR}></View>
Custom Configuration Types
Text field
Copied to your clipboard1configSchema:2 title: 'Configure your application'3 description: 'Set configurable variables for this Slack application'4 properties:5 - title: 'Slack Webhook'6 type: 'string'7 description: 'Please provide the webhook used by this application. Configure in slack.com'8 envKey: 'SLACK_WEBHOOK'9 default: 'https://slack.com/webhook'
Checkbox
Copied to your clipboard1configSchema:2 title: 'Configure your application'3 description: 'Customize this application to meet your needs.'4 properties:5 - title: 'Enable caching'6 description: 'Determines whether or not the app caches.'7 type: 'boolean'8 envKey: 'IS_CACHING_ENABLED'
Dropdown
Copied to your clipboard1configSchema:2 title: 'Configurable Web App'3 description: 'Web application that can be configured.'4 properties:5 - title: 'Frontend background color'6 type: string7 description: 'Please provide the background color for your frontend'8 enum:9 - blue-40010 - celery-40011 - indigo-40012 envKey: FRONTEND_BACKGROUND_COLOR
Secret
Secret screenshot pending bug fix
Copied to your clipboard1configSchema:2 title: 'the title'3 description: 'the description'4 properties:5 - title: 'aws secret key'6 type: 'string'7 secret: true8 envKey: 'AWS_SECRET'
Multiple configuration options
Copied to your clipboard1configSchema:2 title: 'Configurable Web App'3 description: 'Web application that can be configured.'4 properties:5 - title: 'Frontend background color'6 type: string7 description: 'Please provide the background color for your frontend'8 enum:9 - blue-40010 - celery-40011 - indigo-40012 envKey: FRONTEND_BACKGROUND_COLOR13 - title: 'Enable caching'14 description: 'Determines whether or not the app caches.'15 type: 'boolean'16 envKey: 'IS_CACHING_ENABLED'17 - title: 'Slack Webhook'18 type: 'string'19 description: 'Please provide the webhook used by this application. Configure in slack.com'20 envKey: 'SLACK_WEBHOOK'21 default: 'https://slack.com/webhook'222324export const _frontmatter = {}