Apex Basics
- Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce servers in conjunction with calls to the API.
- Using syntax that looks like Java and acts like database stored procedures, Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by Web service requests and from triggers on objects.
Data Types
String : Text , Text Area ,Temp Address , Picklist, Phone, Email, Multiselect Picklist etc…
Integer : Currency , Number
Boolean : True / False ( checkbox )
Date : Date/Month/Year
Datetime: Date/Month/Years H:M:S
Time : Time
Id : Lookup , Master , Record id
Decimal : Currency , Number ( Ex: 123.04 )
Blob : Attachment File (upload)
Variable Declaration:
Syntax:
Datatype variablename;
Note: Here Datatype = string, integer, Boolean, date, time, id, decimal, blob,..
variablename = give any name;
Example:
String AccountName;
Id ParentAccount;
Variable Assignment:
Syntax:
Datatype variablename = value;
Examples:
String instituteName = ‘Sfdc Telugu’;
Here string values are using single quotation ‘ ‘
Id PrimaryOwner = ‘0052x000032J65q’;
Here Id values are using single quotation ‘ ‘
Integer age = 23 ;
integer values are using without single quotation
Note: String and id datatype values are only using single quotation, Remaining datatype values are without using single quotation.
How to Execute variables without apex?
- Goto developer console.
- Ctrl+E
( OR )
- Click on debug menu.
- Open Anonymous window.
- Write the Code
- Click on execute (tick the logs)
- Logs: we can see line by line execution
Same Datatypes we can write bellow example:
Syntax
Datatype variablename1 = value1, variable2=value2 ----- n;
Example
String studentName = ‘John’, phone=’123’,
How to See output for any variable in apex?
For Example
C language : using Printf
C++ : using println
Java : using system.out.println( );
Apex : using system.debug( variablename );
Example:
System.debug(‘studentName’ + studentName);
How to Comment Apex Code?
Using // This symbol for single line comment.
Using /** **/ This symbols for multiple lines comment.
For More:
e-Book Store
S F D C T e l u g u
- Click on eBook
- Fill the Details (mail id must be correct)
- Select Payment method
0 Comments