In the previous chapter, we discussed different methods to deploy an application to different organizations. We also discussed the method of deploying component metadata using Force.com IDE, Force.com Migration Tools and followed it up with the process of distributing an application using packages.
In this chapter, we will discuss the basics of Apex programming and Visualforce page concepts. We'll cover the following topics:
Until now, you have used an out-of-the-box feature-that is, point and click development-to customize your Salesforce org. For example, creating the object's structure, relationships between objects, Process Builders, and approval process to customize it according to your business needs. The point and click development method doesn't require any coding skill.
Apex is the world's first on-demand programming language that allows you to implement complex business requirements and transactions on the Force.com platform. There are two types of application development in Salesforce and they are as follows:
Apex falls under programmatic development. It is a strongly typed object-based language. It remains well connected with your data, schema, and data manipulation using the query and search language. Apex is included in Developer Edition, Lightning Enterprise Edition, Lightning Unlimited Edition and Database.com. You can write Apex classes or triggers in a developer or sandbox organization. As soon as you finish the development of Apex code, you have to write test methods to cover the implemented Apex code. Once you have greater than 75 percent code coverage, you can deploy the particular Apex code to the production organization. The Apex programming language has the following features:
You can write Apex logic in the following ways:
Variables are used to store data in a programming language. In Apex classes and triggers, we can use variables that contain data values. Variables must be similar to a data type, and a particular variable should hold the values of the same data type, for example, integer data types should store integer values. All variables and expressions can have a data type mentioned as follows:
enum
keyword in the variable declaration and then define the list of values.List<DataType> listName = new List<DataType>(); List<String> sList = new List<String>();
Set<DataType> setName = new Set<DataType>(); Set<String> setName = new Set<String>();
Map<PrimitiveKeyDataType, DataType> = mapName = newMap<PrimitiveKeyDataType, DataType>(); Map<Integer, String> mapName = new Map<Integer, String>(); Map<Integer, List<String>> sMap = new Map<Integer,List<String>>();
null
constant)You can create and modify an Apex class through the Setup menu of the Salesforce organization, Force.com IDE, or Developer Console. You can also do this using third-party development tools, for example, MavensMate IDE for Force.com, Welkin Suite IDE, and so on. The best way to interact with Apex classes via the Setup page is by navigating to Setup (gear icon) | Setup | PLATFORM TOOLS | Custom Code | Apex Classes. It will look like the following screenshot:
The preceding screenshot displays the currently available classes in the org. This page allows you to create new classes, edit and delete existing classes, assign security to existing classes, generate an Apex class from a WSDL file, and schedule an Apex class for future run.
Another way to view, create, and modify a class through the Developer Console is by navigating to Setup (gear icon) | Developer Console. It will look like the following screenshot:
Similar to Apex classes, you can create a new Apex trigger from the Setup page, the Force.com IDE, or the Developer Console. When you are using the Setup page, you must navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Custom Code | Apex Triggers.
18.216.149.94