পৃষ্ঠাসমূহ

Search Your Article

CS

Pageviews

Showing posts with label Apex Programming Tutorial. Show all posts
Showing posts with label Apex Programming Tutorial. Show all posts

Wednesday, January 25, 2017

Apex - Overview

What is Apex?

Apex is a proprietary language which has been developed by Salesforce.com. As per the official definition, Apex is a strongly typed, object-oriented programming language that allows developers to execute the flow and transaction control statements on the Force.com platform server in conjunction with calls to the Force.com API.

Apex - Environment

In this chapter, we will understand the environment for our Salesforce Apex development. It is assumed that you already have a Salesforce edition set up for doing Apex development.

Apex - Example

Enterprise Application Development Example

For our tutorial, we will be implementing the CRM application for a Chemical Equipment and Processing company. This company deals with suppliers and provides services. We will work out small code snippets related to this example throughout our tutorial to understand every concept deeply.

Apex - Data Types

Understanding the Data Types

As we have studied, the Apex language is strongly typed so every variable in Apex will be declared with the specific data type. All apex variables are initialized to null initially. As a best practice developer has to make sure it should get assigned proper value otherwise such variables when used, will throw null pointer exceptions or any unhandled expections.

Apex - Variables

Apex Variables

Java and Apex are similar in many manners. Variable declaration in Java and Apex is also quite same. Below are some examples to show how to declare local variables.
String productName = 'HCL';
Integer i=0;

Apex - Strings

String in Apex, as in any other programming language, is any set of characters with no character limit.
Example:
String companyName = 'Abc International';
System.debug('Value companyName variable'+companyName);

Apex - Arrays

Arrays in Apex are basically the same as Lists in Apex. There is no logical distinction between the Arrays and Lists as their internal data structure and methods are also same but the array syntax is little traditional like Java.

Apex - Constants

As in any other programming language, Constants are the variables which do not change their value once declared or assigned a value.

Apex - Decision Making

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

Apex - Loops

Loops are used when a particular piece of code should be repeated with desired number of iteration. Apex supports the standard traditional for loop as well as other advanced types of Loops. Lets have a more detailed look on Loops In Apex.

Apex - Collections

Collections are the type of variable which can store multiple number of records. For example, List can store multiple number of Account object's records. Let's have a detailed overview of all collection types.

Apex - Classes

Class Methods

There are two modifiers for Class Methods in Apex: Public or Protected. Return type is mandatory for method and if method is not returning anything then you must mention void as return type. Body is required for method.

Apex - Objects

An instance of class is called Object. In terms of Salesforce, object could be of class or you could create an object of sObject as well.

Apex - Interfaces

What is an Interface?

An interface is like an Apex class in which none of the methods have been implemented. It only contains the method signatures, but the body of each method is empty. To use an interface, another class must implement it by providing a body for all of the methods contained in the interface.

Apex - DML

In Salesforce, we could perform all the database modification functionalities by two ways:
DML Statements
DML are the actions which are performed in order to perform insert, update, delete, upsert, restoring records, merging records, or converting leads operation.

Apex - Database Methods

Database class methods is another way of working with DML statements which are more flexible than DML Statements like insert, update etc.

Apex - SOSL

Every business or application has search functionality as one of the basic requirements. For this, Salesforce.com provides two major approaches using SOSL and SOQL:

Apex - SOQL

This is Salesforce Object Query Language designed to work with SFDC Database. It can search a record on a given criteria only in single sObject.
Like SOSL, it cannot search across the multiple objects but it does support nested queries.

Apex - Security

Apex security refers to the process of applying security settings and enforcing the sharing rules on running code. Apex classes has security setting which can be controlled via two keywords.

Apex - Invoking

Apex invoking refers to the process of executing the Apex class. Apex class can only be executed when it is invoked via one of the below ways:
  • Triggers and Anonymous block
  • A trigger invoked for specified events.
  • Asynchronous Apex