2

In one of my orgs, I have a simple Visualforce page with just an iframe inside. I don't want the URL to be hard-coded. I didn't develop anything else in this org.

To store this simple URL, which one should I use? Custom Label, Custom Setting or Custom Metadata Type?

0

3 Answers 3

4

I would prefer Custom Setting for your requirement. As per Salesforce guidelines below are purpose of all three

Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user.All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, flows, Apex, and the SOAP API.

Custom metadata is customizable, deployable, packageable, and upgradeable application metadata. It mainly used to define for custom application development.

Custom labels enable developers to create multilingual applications by automatically presenting information in a user's native language.

So ideally Custom Setting is used for data setting.

2
  • thanks for your answer I used custom settings .I think also it is the best option . It is not complected to use instead of custom meta data and because it is just one url , it was not so enoying to recreate the record in the production .
    – Raphael D
    Commented May 12, 2019 at 14:00
  • 1
    I too would agree that if your data is changing from env to env, it should be in custom settings. Otherwise when you version control labels/custom metadata, it is nightmare to properly manage it as you deploy from one env to another. For instance, where I work, many urls are managed in custom labels. Once somebody pushed all labels from version control into sandbox resetting all values to production ones and resulting in sandbox posting to production :)
    – metasync
    Commented May 8, 2022 at 3:21
2

I would use Custom label for this if its just one URL and avoid creating custom metadata or custom setting object.

Had it been a bunch of URL's i would have created a custom metadata object and stored the information in metadata.

The biggest advantage you get with custom metadata over custom settings is they can be deployed via metadata API with your regular deployment. Saves you from hassle of loading data which happens with custom settings.

Also if the hard coded URL is VF page URL i dont think you need to store it anywhere as you can access it using relative path in the lightning component.

3
  • Thank you for your answer , I finally used custom setting .It is working well and not complicated to use.
    – Raphael D
    Commented May 12, 2019 at 14:06
  • I hesitate to store URL's in custom metadata as one can get the source from git/svn he/she gets prod/live endpoints url and might end up hitting them and messing up data. Source tracking /deployable feature is kinda hickup here. Commented May 12, 2019 at 21:15
  • Fair Point @PranayJaiswal, Since the OP mentioned this URL is used in iframe and nothing else is there in this org i suggested it. In my current project we store all our integration end points in custom settings.
    – RedDevil
    Commented May 13, 2019 at 5:51
0

Custom Setting

  • It is similar to the custom object but only limited data types.
  • Two ways we can create a record. 1. List; 2. Hierarchy.
  • In the hierarchy, we can set data based on profile and User.
  • It can be used in the formula field.
  • Only 300 fields are allowed.
  • It will be counted against the total number of custom objects in the org.
  • Data is not deployable.
  • Data will be available in the cache.
  • No SOQL is required to fetch data.
  • Cannot create Tab.
  • Cannot use validation rule and page layout.
  • API name ends with __c

Custom Metadata

  • Similar to a custom setting.
  • More features than Custom Setting and Less than Custom Object.
  • More data types are available compared to a custom setting.
  • Can be set lookup relation with another custom metadata.
  • It can be used in the formula field.
  • Data will be available in the cache.
  • Data is deployable.
  • No SOQL is required to fetch data.
  • Custom Metadata SOQL will not be considered in the governor limit.
  • Cannot create Tab.
  • Can be set validation rule and page layout.
  • API name ends with __mdt

Custom Label

  • Use this to store global variables like OrgURL instead of hardcoding.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .