Production Environment in Salesforce

Deployment on Production Environment in Salesforce

When we move any code or component into a production environment we need to keep the below terms for our understanding:

These terms are-:

  1. Change Set : Change sets are used to send customizations from one Salesforce org to another. Salesforce Change Sets are the mechanism by which changes from one Salesforce environment can be pushed into another Salesforce environment. Salesforce change set best practices means you’ll need to move changes out of an environment. You must first create an Outbound Change Set and point it towards a receiving environment.
  2. Inbound Change Set: An inbound change set in Salesforce is a change set that has been sent from another Salesforce org (Sandbox environment) to the org (production environment) you are logged in to. A change set must be deployed for the changes to take effect.
  3. Outbound Change Set: An outbound change set in Salesforce is a change set created in the Sandbox environment in which you are logged in and sent to the production environment.
Change SetProcess of Change Set

Steps to Use Change Sets in Salesforce

Find Deploy in Quick Find box -> Deployment Setting -> click Edit one of the sandbox and then enable the checkbox for the Inbound change set and Outbound Change set.

After Enable the checkbox please click on Save.

Follow these steps to give Outbound Change set from Sandbox org to Production Environment -:

1. Setup -> search change set in quick find box -> click Outbound Change Set.

Click on New Button for a new Change Set

dont miss out iconDon't forget to check out: Deploying Custom Field and Custom Object Through Change Set | Salesforce Developer Guide

2. Click on New Button. Enter Name, Description and click the ‘Save’ Button.

Write a Name or Description to create a change set

3. Add ‘Change Set Components’ like Apex classes, Objects, Tabs, Validation Rule, Aura Components, Trigger… and Click on Add button.

Click to Add Button to add component
Click to Add To Change Set Button

4. After adding the components in the change set click on Upload Button.

Click on Upload Button

5. After clicking on Upload Button please select a Production Environment like this:

Select the Production Environment Checkbox

6. After Select Production Environment click on the Upload Button. Then the change set is successfully uploaded to the Production Environment.

7. Ensure that the allow Inbound change should be enabled in a production environment like this:

Inbound change

8. Now go to production and then select the outbound change Sets and Click Validate button. Once the change set is validated then further proceed for the Deployment.

change set details
Change Set Validate on Production
Test Class
Change Set Deploy on Production

Test Class in Salesforce:

Testing is an important part of SDLC. Salesforce requires at least 75% of your code to be covered by our test classes. Salesforce has done that to make sure that our code doesn’t break in any situation in Production.

It is automation Testing that is provided by Salesforce by Default. when you write all the test cases in the test class then it will automatically test all the test cases.

dont miss out iconCheck out another amazing blog by Aman here: What is Multi-factor Authentication (MFA)? When and How to Use it? | Salesforce Developer Guide

When test cases are not covered in the given test class, then it will show errors like these which are described below:

Note:

1. If you are giving the apex class or apex test class then ensure that the code coverage of the test class is 75% or more than 75%. If code coverage of the apex class is not accurate then you will be facing this error like that:

apex test class
Code Coverage Error

2. In your Apex class there is found any error like duplicate Function, Name, Email or Expected or Actual Answer in a test class or something else then the error shows like this:

duplicate Function
Found Error when Deployed the apex class and apex test class

3. If found no error is when validating your change set on production that means Change Set is Successfully validated and after that can start the deployment like that:

Successfully Deployment on Production

Please refer to this module for more read about the Change set: https://trailhead.salesforce.com/en/content/learn/modules/declarative-change-set-development

Responses

Popular Salesforce Blogs