I am new to development, I have to deploy some apex classes to production and I am using change set for this. While adding components to the change set, we get an option to add dependencies. I checked dependency for one of my class and attaching this image here. My question is do I need to add all the object and fields listed here to change set. Also what if other apex class has same object or fields listed here
1 Answer
Adding dependency makes sure that you are not missing any components that's needed for deployment.
Example let's say you missed adding a field to the change set that does not exist yet in the target environment, the deployment will fail.
So if you know that the target orgs have all the fields and objects that your apex class is referencing you may skip adding dependencies.
It all depends on how much in sync your source and target environments are and what components you are moving. Sometimes adding all dependency is needed for smoother deployments.
Some considerations when moving all dependent metadata is to make sure you are not adding components that will override something that's unique to PROD.
One common example is metadata like named credential where your sandbox may be connected to a different endpoint than production and hence you may want to remove this component from changeset before moving to Production.
For the next question
If you have two classes depending on an object then that object is added only once to changeset when you say "Add all dependencies". Nothing is duplicated in Changeset.
-
there is a custom setting referenced in my apex class and I have added it to the change set but when I validated, it gave error- No such column 'Link__c' on entity 'About_Us__c'. Do I have to deploy custom setting before apex class– jaisoCommented Jul 6, 2021 at 4:21
-
You have to add all custom settings and its field. Like make sure Link__c field is also included. Note Link__c field will appear when you choose custom fields from the drop-down. Commented Jul 6, 2021 at 4:23