I'm new to Salesforce, though an experienced Java developer and I'm trying to load my App's configuration using the recommended method of custom meta data.
I've found this quite poorly documented with most of the hits with Google being marketing material about how good it is, but rather lacking in good concrete examples of usage. These are the approaches I've tried, pulled from online examples, none worked for various reasons. I have two configurations defined,
Thing_REST_stable config; System.debug('config : ' + config); // Null as expected Thing_REST__mdt config = new Thing_REST__mdt(); System.debug('config : ' + config); // Empty, unexpected Thing_REST__mdt config = new Thing_REST_stable(); System.debug('config : ' + config); // Empty, unexpected Thing_REST__mdt config = [SELECT * FROM Thing_REST_stable]; System.debug('config : ' + config); // fails to compile.
These configurations contain details such as the endpoint, version & credentials for external REST connections. The documentation for this is very poor: https://trailhead.salesforce.com/en/content/learn/modules/custom_metadata_types
- How do I load these configs with Apex code?
- How do I select Thing_REST_stable in live code?
- How do I select Thing_REST_latest in my test code?
- Can you point out some good examples, documentation?