Apex Designer Documentation
What's New
Getting Started
Projects
Business Objects
Processes
User Interfaces
App Behaviors
Files
Dependencies
Project Settings
Libraries
Patterns and Best Practices
App Showcase
Frequently Asked Questions

Accessing Environment Variables

Adjust your app behavior at runtime using environment variables

Blank Profile Image
Written by David Knapp
Updated 3 years ago
Less than a minute read

If a behavior needs information that can only be known at runtime, environment variables are the answer. You can reference environment variables in any server-side code (Business Object Behaviors, App Behaviors and Reusable Behaviors) by accessing "process.env.<name of environment variable>".

Here is an example that prepares the url of a page in the app:

if (!process.env.appUrl) {
	console.error('Please specify the appUrl environment variable with the full path to the app.');
}
const suppliersUrl = process.env.appUrl+'/Suppliers';

It is a best practice to check that the environment variable is defined. In the example above, if it is not specified an error is output to the logs.

If the environment variable is vital to the application and the app should not be run without it, you can do this:

if (!process.env.appUrl) {
	throw Please specify the appUrl environment variable with the full path to the app.'
}
const suppliersUrl = process.env.appUrl+'/Suppliers';

Setting Environment Variables During Development

Non-sensitive environment variables (appUrl for example) can be set in Settings + Environment Variables. Sensitive environment variables (passwords for example) can be set on the App Manager.

Setting Environment Variables in Runtime Environments

The method of setting environment variables in runtime environments depends on your deployment process and target environment. Check with your Dev/Ops specialists to see how to do it.

Powered by Apex Designer
Terms of ServicePrivacy Policy
© 2017-2024 Apex Process Consultants