Salesforce Environment Variables
A simple library for using Custom Metadata to manage simple Key/Value Environment variables
idea inspired by Ralph Callaway's work
Usage
install in org
git clone https://github.com/ChuckJonas/Salesforce-Environment-Vars.git
cd Salesforce-Environment-Vars
mkdir deploy
sfdx force:source:convert -d deploy/
sfdx force:mdapi:deploy -d deploy/ -u "YOUR_USERNAME_HERE" -l RunSpecifiedTests -r EnvTests
NOTE: This application comes with a custom user interface for easier management of the ENV Vars. If you'd prefer not to use it, delete the following before deploying:
force-app/main/default/pages
force-app/main/default/staticresources
Setup
If UI was installed, navigate to /apex/env_vars
and setup your Environment Variables. Otherwise, just manage like any other CustomMetadata.
Notes
The following types are currently supported:
String
Integer
Decimal
Boolean
: Format:true
orfalse
String[]
: Format:["a","b","c"]
Map<String,String>
: Format:{"456":"xyz","123":"abc"}
Access in apex
Use Env.get()
to access by passing in the DeveloperName
:
// cast to datatype
Integer retries = (Integer) Env.get('Account_Sync_Retries');
String[] types = (String[]) Env.get('Status_Types');
Contributing/Modifying
This project is built off the B.A.S.S. Stack. See Readme for details on how to develop.