Skip to content

A simple solution for managing environment variables in salesforce

License

Notifications You must be signed in to change notification settings

callawaycloud/Salesforce-Environment-Vars

Repository files navigation

Salesforce Environment Variables

A simple library which uses Custom Metadata to manage simple Key/Value Environment variables. Includes a custom UI to make configuration as easy & error free as possible.

UI

📦 Install

via sfdx-cli sfdx force:package:install --package 04t6O000001J2gsQAC -u [email protected]

via url login and navigate to /packaging/installPackage.apexp?p0=04t6O000001J2gsQAC. Choose Install for: Admin Only.

Upgrading

This project has been updated to a namespaced unlocked package. If you installed before the namespace was added, and want to stay up-to-sync with the latest improvements, then please follow the manual migration process!

🔨 Usage

  1. Open Environment Variables from the app switcher (or "tabs" in classic)
  2. Add and Save some env-vars
  3. Use in Apex, Formulas or javascript applications.

Apex

//basic usage
Map<String,String> fieldMap = (Map<String,String>) VARS.ENV.get('MY_MAP');

//with a string transform
Map<String,String> fieldMap = (String[]) VARS.ENV.get('MY_ARRAY', VARS.ENV.Transform.TO_LOWER);

// with ANY json
Foo fieldMap = (Foo) VARS.ENV.get('MY_FOO', Foo.class);

Formula

$CustomMetadata.VARS__ENV__mdt.FIELD_MAP.Val__c

Note: Only the first 255 characters will be returned in formula!

✨Features

Currently supports the following types:

  • String
  • Integer
  • Decimal
  • Boolean: Format: true or false
  • String[]: Format: ["a","b","c"]
  • Map<String,String>: Format: {"456":"xyz","123":"abc"}
  • ANY: Any valid JSON string

Copy apex/formula code to clipboard

copy code

"Type-checking" to prevent user input errors

  • Simple type checking on primitive types.
  • ability to apply JSON Schema to ANY json type!

type checking

"Secret" Values Support (Optional)

Salesforce_-_Unlimited_Edition

In order to enable, follow these instructions.

Quick Find

Quickly filter VARS based on either key or value string search.

Auto-formatting of JSON types

Automatically formats JSON after editing

Ability to group like "VARS" together

https___drive-connect-5888-dev-ed--vars_visualforce_com_apex_env_vars_local_1

Ability to add Notes

Add information about how it's used, how to manage it, etc

notes

🤝 Contributing/Modifying

Project Overview:

  • env-vars: Salesforce metadata for core env-vars functionality
  • app: React UI for managing env-vars. Uses B.A.S.S. Stack
  • env-vars-encrypt: managed package to allow for "secret" vars
  • sf-env-vars-npm: npm package to make using env-vars easy in js applications

** Powered by ** Callaway Cloud Consulting