How to load configuration from custom meta data












3














I'm new to Salesforce and I'm trying to load my App's configuration using the recommended method of custom meta data. This is very poorly documented with most of the hits with Google being marketing material about how good it is but lacking 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 & Thing_REST_latest.



    Thing_REST_stable config;
System.debug('config : ' + config); // Null

Thing_REST__mdt config = new Thing_REST__mdt();
System.debug('config : ' + config); // Empty

Thing_REST__mdt config = new Thing_REST_stable();
System.debug('config : ' + config); // Empty

Thing_REST__mdt conf = [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?

  • 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?










share|improve this question









New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What are the "Thing_REST_stable" and "Thing_REST_latest: in your code? What do you want to achieve through custom metadata?
    – Naval Sharma
    3 hours ago












  • I am trying to 'load my configuration', as per first sentence, they are the custom metadata objects, created via the UI.
    – Martin of Hessle
    3 hours ago












  • What is your use case mate? Looks like you want to query Custom Metadata?
    – Naval Sharma
    3 hours ago










  • I have an external REST interface and I do not want credentials in the code, I'm trying to load those, custom metadata seems to be the recommended way to do this, but loading configurations seems a pita in salesforce. This would be trivially easy in most languages. One line in java, System.getenv('endpoint')
    – Martin of Hessle
    2 hours ago
















3














I'm new to Salesforce and I'm trying to load my App's configuration using the recommended method of custom meta data. This is very poorly documented with most of the hits with Google being marketing material about how good it is but lacking 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 & Thing_REST_latest.



    Thing_REST_stable config;
System.debug('config : ' + config); // Null

Thing_REST__mdt config = new Thing_REST__mdt();
System.debug('config : ' + config); // Empty

Thing_REST__mdt config = new Thing_REST_stable();
System.debug('config : ' + config); // Empty

Thing_REST__mdt conf = [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?

  • 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?










share|improve this question









New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What are the "Thing_REST_stable" and "Thing_REST_latest: in your code? What do you want to achieve through custom metadata?
    – Naval Sharma
    3 hours ago












  • I am trying to 'load my configuration', as per first sentence, they are the custom metadata objects, created via the UI.
    – Martin of Hessle
    3 hours ago












  • What is your use case mate? Looks like you want to query Custom Metadata?
    – Naval Sharma
    3 hours ago










  • I have an external REST interface and I do not want credentials in the code, I'm trying to load those, custom metadata seems to be the recommended way to do this, but loading configurations seems a pita in salesforce. This would be trivially easy in most languages. One line in java, System.getenv('endpoint')
    – Martin of Hessle
    2 hours ago














3












3








3







I'm new to Salesforce and I'm trying to load my App's configuration using the recommended method of custom meta data. This is very poorly documented with most of the hits with Google being marketing material about how good it is but lacking 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 & Thing_REST_latest.



    Thing_REST_stable config;
System.debug('config : ' + config); // Null

Thing_REST__mdt config = new Thing_REST__mdt();
System.debug('config : ' + config); // Empty

Thing_REST__mdt config = new Thing_REST_stable();
System.debug('config : ' + config); // Empty

Thing_REST__mdt conf = [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?

  • 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?










share|improve this question









New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm new to Salesforce and I'm trying to load my App's configuration using the recommended method of custom meta data. This is very poorly documented with most of the hits with Google being marketing material about how good it is but lacking 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 & Thing_REST_latest.



    Thing_REST_stable config;
System.debug('config : ' + config); // Null

Thing_REST__mdt config = new Thing_REST__mdt();
System.debug('config : ' + config); // Empty

Thing_REST__mdt config = new Thing_REST_stable();
System.debug('config : ' + config); // Empty

Thing_REST__mdt conf = [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?

  • 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?







apex configuration custom-metadata custom-metadata-types






share|improve this question









New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 hour ago





















New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 4 hours ago









Martin of Hessle

183




183




New contributor




Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Martin of Hessle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • What are the "Thing_REST_stable" and "Thing_REST_latest: in your code? What do you want to achieve through custom metadata?
    – Naval Sharma
    3 hours ago












  • I am trying to 'load my configuration', as per first sentence, they are the custom metadata objects, created via the UI.
    – Martin of Hessle
    3 hours ago












  • What is your use case mate? Looks like you want to query Custom Metadata?
    – Naval Sharma
    3 hours ago










  • I have an external REST interface and I do not want credentials in the code, I'm trying to load those, custom metadata seems to be the recommended way to do this, but loading configurations seems a pita in salesforce. This would be trivially easy in most languages. One line in java, System.getenv('endpoint')
    – Martin of Hessle
    2 hours ago


















  • What are the "Thing_REST_stable" and "Thing_REST_latest: in your code? What do you want to achieve through custom metadata?
    – Naval Sharma
    3 hours ago












  • I am trying to 'load my configuration', as per first sentence, they are the custom metadata objects, created via the UI.
    – Martin of Hessle
    3 hours ago












  • What is your use case mate? Looks like you want to query Custom Metadata?
    – Naval Sharma
    3 hours ago










  • I have an external REST interface and I do not want credentials in the code, I'm trying to load those, custom metadata seems to be the recommended way to do this, but loading configurations seems a pita in salesforce. This would be trivially easy in most languages. One line in java, System.getenv('endpoint')
    – Martin of Hessle
    2 hours ago
















What are the "Thing_REST_stable" and "Thing_REST_latest: in your code? What do you want to achieve through custom metadata?
– Naval Sharma
3 hours ago






What are the "Thing_REST_stable" and "Thing_REST_latest: in your code? What do you want to achieve through custom metadata?
– Naval Sharma
3 hours ago














I am trying to 'load my configuration', as per first sentence, they are the custom metadata objects, created via the UI.
– Martin of Hessle
3 hours ago






I am trying to 'load my configuration', as per first sentence, they are the custom metadata objects, created via the UI.
– Martin of Hessle
3 hours ago














What is your use case mate? Looks like you want to query Custom Metadata?
– Naval Sharma
3 hours ago




What is your use case mate? Looks like you want to query Custom Metadata?
– Naval Sharma
3 hours ago












I have an external REST interface and I do not want credentials in the code, I'm trying to load those, custom metadata seems to be the recommended way to do this, but loading configurations seems a pita in salesforce. This would be trivially easy in most languages. One line in java, System.getenv('endpoint')
– Martin of Hessle
2 hours ago




I have an external REST interface and I do not want credentials in the code, I'm trying to load those, custom metadata seems to be the recommended way to do this, but loading configurations seems a pita in salesforce. This would be trivially easy in most languages. One line in java, System.getenv('endpoint')
– Martin of Hessle
2 hours ago










2 Answers
2






active

oldest

votes


















2














Custom Metadata isn't just a drop-in configuration load/save system. It acts in most cases like other metadata objects and variables in Apex and is subject to exactly the same syntax and limitations. Most of the issues you have below have to do with Apex and SOQL syntax, rather than Custom Metadata as such.



If the API name of your Custom Metadata record is Thing_REST__mdt, you must always refer to it as such. If you're maintaining more than one configuration, and a single record defines a configuration, you can populate the name of that configuration (such as Thing_REST_stable) in the record's DeveloperName field, and then query based on that field to access a specific configuration.



Examples



Thing_REST_stable config;
System.debug('config : ' + config);


This is an uninitialized variable, and like any other in Apex is null. Thing_REST_stable isn't the name of the metadata record, but might be the name of a specific configuration (as above).



Thing_REST__mdt config = new Thing_REST_stable();
System.debug('config : ' + config);


Custom metadata objects instantiated in code are blank, much like sObjects. Custom metadata classes do not have static methods like Custom Settings that instantiate them for you. You'll get a syntax error here because Thing_REST_stable and Thing_REST__mdt aren't the same types.



Thing_REST__mdt conf = [SELECT * FROM Thing_REST_stable];
System.debug('config : ' + config);


This is closest to being correct, but SELECT * is not valid SOQL, and you must use the full name of your object (Thing_REST__mdt) in your FROM clause. You might do



Thing_REST__mdt conf = [SELECT My_Field__c, My_Preference__c FROM Thing_REST__mdt WHERE DeveloperName = 'Thing_REST_stable'];


to source two specific fields from a defined configuration.



Thing_REST__mdt config = new Thing_REST__mdt();
System.debug('config : ' + config);


This is the same as the one above, but it's closer to being valid because you use your object's API name Thing_REST__mdt in both locations.



Storing Credentials



The best place to store credentials in Salesforce is not Custom Metadata, which can be read by anyone who has View Setup and Configuration permission. It's a Named Credential, which securely protects the credentials and handles OAuth authentication for you.



Custom Metadata and Custom Settings records can only be secured from users and system administrators in the context of a Managed Package, where they can be set to Protected.






share|improve this answer























  • Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
    – Martin of Hessle
    1 hour ago



















1














You can query custom metadata records with a simple SOQL and here is the syntax -



SELECT (ALL FIELDS WITH COMMA SEPARATED) FROM Thing_REST__mdt WHERE DeveloperName = '*metadata_record_developer_name*'



You can not use * like sql syntax. You have to provide all fields API names in the query.




Example :



String devName = 'Thing_REST_stable';

Thing_REST__mdt thingsRestSetting = [ SELECT MasterLabel, DeveloperName FROM Thing_REST__mdt WHERE DeveloperName =:devName ];


You can pass the record developer name in the devName variable based on your environment. If the environment is testing then devName will be set to "Thing_REST_latest".




You can learn more about custom metadata from here.







share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "459"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Martin of Hessle is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f244900%2fhow-to-load-configuration-from-custom-meta-data%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Custom Metadata isn't just a drop-in configuration load/save system. It acts in most cases like other metadata objects and variables in Apex and is subject to exactly the same syntax and limitations. Most of the issues you have below have to do with Apex and SOQL syntax, rather than Custom Metadata as such.



    If the API name of your Custom Metadata record is Thing_REST__mdt, you must always refer to it as such. If you're maintaining more than one configuration, and a single record defines a configuration, you can populate the name of that configuration (such as Thing_REST_stable) in the record's DeveloperName field, and then query based on that field to access a specific configuration.



    Examples



    Thing_REST_stable config;
    System.debug('config : ' + config);


    This is an uninitialized variable, and like any other in Apex is null. Thing_REST_stable isn't the name of the metadata record, but might be the name of a specific configuration (as above).



    Thing_REST__mdt config = new Thing_REST_stable();
    System.debug('config : ' + config);


    Custom metadata objects instantiated in code are blank, much like sObjects. Custom metadata classes do not have static methods like Custom Settings that instantiate them for you. You'll get a syntax error here because Thing_REST_stable and Thing_REST__mdt aren't the same types.



    Thing_REST__mdt conf = [SELECT * FROM Thing_REST_stable];
    System.debug('config : ' + config);


    This is closest to being correct, but SELECT * is not valid SOQL, and you must use the full name of your object (Thing_REST__mdt) in your FROM clause. You might do



    Thing_REST__mdt conf = [SELECT My_Field__c, My_Preference__c FROM Thing_REST__mdt WHERE DeveloperName = 'Thing_REST_stable'];


    to source two specific fields from a defined configuration.



    Thing_REST__mdt config = new Thing_REST__mdt();
    System.debug('config : ' + config);


    This is the same as the one above, but it's closer to being valid because you use your object's API name Thing_REST__mdt in both locations.



    Storing Credentials



    The best place to store credentials in Salesforce is not Custom Metadata, which can be read by anyone who has View Setup and Configuration permission. It's a Named Credential, which securely protects the credentials and handles OAuth authentication for you.



    Custom Metadata and Custom Settings records can only be secured from users and system administrators in the context of a Managed Package, where they can be set to Protected.






    share|improve this answer























    • Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
      – Martin of Hessle
      1 hour ago
















    2














    Custom Metadata isn't just a drop-in configuration load/save system. It acts in most cases like other metadata objects and variables in Apex and is subject to exactly the same syntax and limitations. Most of the issues you have below have to do with Apex and SOQL syntax, rather than Custom Metadata as such.



    If the API name of your Custom Metadata record is Thing_REST__mdt, you must always refer to it as such. If you're maintaining more than one configuration, and a single record defines a configuration, you can populate the name of that configuration (such as Thing_REST_stable) in the record's DeveloperName field, and then query based on that field to access a specific configuration.



    Examples



    Thing_REST_stable config;
    System.debug('config : ' + config);


    This is an uninitialized variable, and like any other in Apex is null. Thing_REST_stable isn't the name of the metadata record, but might be the name of a specific configuration (as above).



    Thing_REST__mdt config = new Thing_REST_stable();
    System.debug('config : ' + config);


    Custom metadata objects instantiated in code are blank, much like sObjects. Custom metadata classes do not have static methods like Custom Settings that instantiate them for you. You'll get a syntax error here because Thing_REST_stable and Thing_REST__mdt aren't the same types.



    Thing_REST__mdt conf = [SELECT * FROM Thing_REST_stable];
    System.debug('config : ' + config);


    This is closest to being correct, but SELECT * is not valid SOQL, and you must use the full name of your object (Thing_REST__mdt) in your FROM clause. You might do



    Thing_REST__mdt conf = [SELECT My_Field__c, My_Preference__c FROM Thing_REST__mdt WHERE DeveloperName = 'Thing_REST_stable'];


    to source two specific fields from a defined configuration.



    Thing_REST__mdt config = new Thing_REST__mdt();
    System.debug('config : ' + config);


    This is the same as the one above, but it's closer to being valid because you use your object's API name Thing_REST__mdt in both locations.



    Storing Credentials



    The best place to store credentials in Salesforce is not Custom Metadata, which can be read by anyone who has View Setup and Configuration permission. It's a Named Credential, which securely protects the credentials and handles OAuth authentication for you.



    Custom Metadata and Custom Settings records can only be secured from users and system administrators in the context of a Managed Package, where they can be set to Protected.






    share|improve this answer























    • Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
      – Martin of Hessle
      1 hour ago














    2












    2








    2






    Custom Metadata isn't just a drop-in configuration load/save system. It acts in most cases like other metadata objects and variables in Apex and is subject to exactly the same syntax and limitations. Most of the issues you have below have to do with Apex and SOQL syntax, rather than Custom Metadata as such.



    If the API name of your Custom Metadata record is Thing_REST__mdt, you must always refer to it as such. If you're maintaining more than one configuration, and a single record defines a configuration, you can populate the name of that configuration (such as Thing_REST_stable) in the record's DeveloperName field, and then query based on that field to access a specific configuration.



    Examples



    Thing_REST_stable config;
    System.debug('config : ' + config);


    This is an uninitialized variable, and like any other in Apex is null. Thing_REST_stable isn't the name of the metadata record, but might be the name of a specific configuration (as above).



    Thing_REST__mdt config = new Thing_REST_stable();
    System.debug('config : ' + config);


    Custom metadata objects instantiated in code are blank, much like sObjects. Custom metadata classes do not have static methods like Custom Settings that instantiate them for you. You'll get a syntax error here because Thing_REST_stable and Thing_REST__mdt aren't the same types.



    Thing_REST__mdt conf = [SELECT * FROM Thing_REST_stable];
    System.debug('config : ' + config);


    This is closest to being correct, but SELECT * is not valid SOQL, and you must use the full name of your object (Thing_REST__mdt) in your FROM clause. You might do



    Thing_REST__mdt conf = [SELECT My_Field__c, My_Preference__c FROM Thing_REST__mdt WHERE DeveloperName = 'Thing_REST_stable'];


    to source two specific fields from a defined configuration.



    Thing_REST__mdt config = new Thing_REST__mdt();
    System.debug('config : ' + config);


    This is the same as the one above, but it's closer to being valid because you use your object's API name Thing_REST__mdt in both locations.



    Storing Credentials



    The best place to store credentials in Salesforce is not Custom Metadata, which can be read by anyone who has View Setup and Configuration permission. It's a Named Credential, which securely protects the credentials and handles OAuth authentication for you.



    Custom Metadata and Custom Settings records can only be secured from users and system administrators in the context of a Managed Package, where they can be set to Protected.






    share|improve this answer














    Custom Metadata isn't just a drop-in configuration load/save system. It acts in most cases like other metadata objects and variables in Apex and is subject to exactly the same syntax and limitations. Most of the issues you have below have to do with Apex and SOQL syntax, rather than Custom Metadata as such.



    If the API name of your Custom Metadata record is Thing_REST__mdt, you must always refer to it as such. If you're maintaining more than one configuration, and a single record defines a configuration, you can populate the name of that configuration (such as Thing_REST_stable) in the record's DeveloperName field, and then query based on that field to access a specific configuration.



    Examples



    Thing_REST_stable config;
    System.debug('config : ' + config);


    This is an uninitialized variable, and like any other in Apex is null. Thing_REST_stable isn't the name of the metadata record, but might be the name of a specific configuration (as above).



    Thing_REST__mdt config = new Thing_REST_stable();
    System.debug('config : ' + config);


    Custom metadata objects instantiated in code are blank, much like sObjects. Custom metadata classes do not have static methods like Custom Settings that instantiate them for you. You'll get a syntax error here because Thing_REST_stable and Thing_REST__mdt aren't the same types.



    Thing_REST__mdt conf = [SELECT * FROM Thing_REST_stable];
    System.debug('config : ' + config);


    This is closest to being correct, but SELECT * is not valid SOQL, and you must use the full name of your object (Thing_REST__mdt) in your FROM clause. You might do



    Thing_REST__mdt conf = [SELECT My_Field__c, My_Preference__c FROM Thing_REST__mdt WHERE DeveloperName = 'Thing_REST_stable'];


    to source two specific fields from a defined configuration.



    Thing_REST__mdt config = new Thing_REST__mdt();
    System.debug('config : ' + config);


    This is the same as the one above, but it's closer to being valid because you use your object's API name Thing_REST__mdt in both locations.



    Storing Credentials



    The best place to store credentials in Salesforce is not Custom Metadata, which can be read by anyone who has View Setup and Configuration permission. It's a Named Credential, which securely protects the credentials and handles OAuth authentication for you.



    Custom Metadata and Custom Settings records can only be secured from users and system administrators in the context of a Managed Package, where they can be set to Protected.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 1 hour ago

























    answered 2 hours ago









    David Reed

    29.9k61746




    29.9k61746












    • Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
      – Martin of Hessle
      1 hour ago


















    • Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
      – Martin of Hessle
      1 hour ago
















    Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
    – Martin of Hessle
    1 hour ago




    Thanks a good answer, clear & too the point, sorry I don't have the score to up vote.
    – Martin of Hessle
    1 hour ago













    1














    You can query custom metadata records with a simple SOQL and here is the syntax -



    SELECT (ALL FIELDS WITH COMMA SEPARATED) FROM Thing_REST__mdt WHERE DeveloperName = '*metadata_record_developer_name*'



    You can not use * like sql syntax. You have to provide all fields API names in the query.




    Example :



    String devName = 'Thing_REST_stable';

    Thing_REST__mdt thingsRestSetting = [ SELECT MasterLabel, DeveloperName FROM Thing_REST__mdt WHERE DeveloperName =:devName ];


    You can pass the record developer name in the devName variable based on your environment. If the environment is testing then devName will be set to "Thing_REST_latest".




    You can learn more about custom metadata from here.







    share|improve this answer




























      1














      You can query custom metadata records with a simple SOQL and here is the syntax -



      SELECT (ALL FIELDS WITH COMMA SEPARATED) FROM Thing_REST__mdt WHERE DeveloperName = '*metadata_record_developer_name*'



      You can not use * like sql syntax. You have to provide all fields API names in the query.




      Example :



      String devName = 'Thing_REST_stable';

      Thing_REST__mdt thingsRestSetting = [ SELECT MasterLabel, DeveloperName FROM Thing_REST__mdt WHERE DeveloperName =:devName ];


      You can pass the record developer name in the devName variable based on your environment. If the environment is testing then devName will be set to "Thing_REST_latest".




      You can learn more about custom metadata from here.







      share|improve this answer


























        1












        1








        1






        You can query custom metadata records with a simple SOQL and here is the syntax -



        SELECT (ALL FIELDS WITH COMMA SEPARATED) FROM Thing_REST__mdt WHERE DeveloperName = '*metadata_record_developer_name*'



        You can not use * like sql syntax. You have to provide all fields API names in the query.




        Example :



        String devName = 'Thing_REST_stable';

        Thing_REST__mdt thingsRestSetting = [ SELECT MasterLabel, DeveloperName FROM Thing_REST__mdt WHERE DeveloperName =:devName ];


        You can pass the record developer name in the devName variable based on your environment. If the environment is testing then devName will be set to "Thing_REST_latest".




        You can learn more about custom metadata from here.







        share|improve this answer














        You can query custom metadata records with a simple SOQL and here is the syntax -



        SELECT (ALL FIELDS WITH COMMA SEPARATED) FROM Thing_REST__mdt WHERE DeveloperName = '*metadata_record_developer_name*'



        You can not use * like sql syntax. You have to provide all fields API names in the query.




        Example :



        String devName = 'Thing_REST_stable';

        Thing_REST__mdt thingsRestSetting = [ SELECT MasterLabel, DeveloperName FROM Thing_REST__mdt WHERE DeveloperName =:devName ];


        You can pass the record developer name in the devName variable based on your environment. If the environment is testing then devName will be set to "Thing_REST_latest".




        You can learn more about custom metadata from here.








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 42 mins ago









        codeyinthecloud

        3,239423




        3,239423










        answered 2 hours ago









        Naval Sharma

        88228




        88228






















            Martin of Hessle is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Martin of Hessle is a new contributor. Be nice, and check out our Code of Conduct.













            Martin of Hessle is a new contributor. Be nice, and check out our Code of Conduct.












            Martin of Hessle is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f244900%2fhow-to-load-configuration-from-custom-meta-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            サソリ

            広島県道265号伴広島線

            Accessing regular linux commands in Huawei's Dopra Linux