What is Apex Code in Salesforce com? – Apex Examples

Apex is an object-oriented programming language that allows developers to execute flow and transaction control statements on the SalesForce.com platform server in conjunction with calls to the SalesForce.com API.proprietary language. Apex is an improvement stage for building programming as a help (SaaS) applications on top of Salesforce.com’s client relationship with the executive’s (CRM) usefulness. Summit permits designers to get to Salesforce.com’s back-end information base and customer worker interfaces to make outsider SaaS applications.

Peak incorporates an application program interface (API) that designers can use to get client information on Salesforce.com. This API permits designers to utilize basic SaaS parts, similar to Web gadgets or a multi-occupant information base, without the need to grow a large part of the foundation generally related to SaaS programs. 

Summit applications are typically facilitated and run straightforwardly by Salesforce.com’s workers. No establishment on a client’s nearby PC is fundamental on account of this facilitating. A client buys a given Apex program through AppExchange, Saleforce.com’s Web gateway, for additional CRM items. The client is then ready to get to the program through the standard interface. When made, an application can be distributed for public use or kept hidden, such as an exclusive extra. 

The Apex stage comprises of three apparatuses, Builder, API, and Code. 

• Apex Builder is an on-request segment that permits simple, simplified customization with a restricted arrangement of highlights. Summit Builder applications are generally simple to make yet should draw on a limited, pre-characterized set of interface components and business rationale calculations. 

• Apex API is a strategy for recovering crude information from Salesforce.com’s workers. The API is utilized by programs outside of Salesforce.com, similar to Java applications, that need admittance to data on a customer’s Salesforce.com account. 

• Apex Code is an ultimately included programming language that is executed on Salesforce.com’s servers. Summit Code has implicit techniques for getting to client information. The speech was made accessible to engineers in Salesforce.com’s Winter ’07 release. Zenith Code offers both adaptabilities in creating for the Apex API while decreasing calls among worker and customer. While Apex API programs must speak with the Salesforce.com worker each time they access or record information. Apex Code applications handle these exchanges locally, requiring customer worker correspondence when taking client input and showing the final product. 

In April 2007, Saleforce.com declared the Salesforce.com Platform Edition. This rendition lets clients access Apex applications without buying into the organization’s center CRM item. 

Apex is a specifically object-situated programming language that permits engineers to execute stream and exchange control articulations on Salesforce workers’ calls to the API. Utilizing linguistic structure that appears as though Java and acts as information base put away methods, Apex empowers engineers to add business rationale to most framework occasions, including button clicks, related record updates, and Visualforce pages. Peak code can be started by Web administration demands and from triggers on objects. 

Zenith gives worked in help to normal Lightning Platform expressions, including: 

• Data control language (DML) calls, for example, INSERT, UPDATE, and DELETE, that incorporate implicit DmlException dealing with 

• Inline Salesforce Object Query Language (SOQL) and Salesforce Object Search Language (SOSL) questions that return arrangements of subject records 

• Looping that considers mass preparing of different records all at once 

• Locking punctuation that forestalls record update clashes 

• Custom public API calls that can be worked by putting away Apex techniques 

gold ira scams  buyer beware

• Warnings and blunders gave when a client attempts to alter or erase a custom item or field that is referred to by Apex 

APEX is Simple to utilize 

Summit depends on natural Java sayings, such as factor and articulation language structure, block, contingent proclamation punctuation, circle grammar, item, and exhibit documentation. Apex presents new components; it utilizes language structure and semantics that are straightforward and empower the Lightning Platform’s productive utilization. Accordingly, Apex produces code that is both concise and simple to compose. 

Information centered 

The peak is intended to string together numerous inquiry and DML explanations into a solitary work unit on the Salesforce worker. Designers use an information base to put away techniques to string together various exchange proclamations on a data set worker. Like other information base put away techniques, Apex doesn’t endeavor to offer general help for delivering components in the UI.


Apex programming examples:

What is Apex programming in Salesforce?
Apex programming represents an object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce servers in conjunction with the API calls.

What is the Apex trigger in Salesforce?
Apex triggers enable users to perform custom actions before events or after events to records in Salesforce. Triggers can be: insertions, updates, or deletions, and they are active by default when created. Triggers can be defined for top-level standard objects, such as Account or Contact, custom objects, and some standard child objects. Triggers

How to call apex class from javascript in Salesforce?
Call apex class from javascript in Salesforce, go to Setup then Object then Buttons, and find links and Actions section. When you reach the Action sections, please Click New Button or Link.

How to get selected picklist values in apex Salesforce?
To check picklist values in apex salesforce in Visualforce, you must create the following method Apex:
public with sharing DynamicPickListFectcher {

    public static List getPicklistOptions(String objectApiName, String fieldApiName) {
        List picklistOptions = new List();
        try {
            Schema.SObjectType obj_describe = Schema.getGlobalDescribe().get(objectApiName) ;
            Schema.DescribeSObjectResult obj_describe_result = obj_describe.getDescribe() ;
            Map<String,Schema.SObjectField> fields = obj_describe_result.fields.getMap() ;
            Schema.DescribeFieldResult fieldResult = fields.get(fieldApiName).getDescribe();
            List ple = fieldResult.getPicklistValues();
            SelectOptionObj option = null;
            for (Schema.PicklistEntry pickListVal : ple) {
                option = new SelectOptionObj(pickListVal.getLabel(), pickListVal.getValue(), pickListVal.isDefaultValue());
        } catch (Exception ex) {
            throw new AuraHandledException(ex.getMessage());
        return picklistOptions;
    public class SelectOptionObj {
        public String label { get; set; }
        public String value { get; set; }
        public Boolean isDefault {get; set;}
        public SelectOptionObj(String label, String val,Boolean isDefault) {
            this.label = label;
            this.value = val;
            this.isDefault = isDefault;

How to schedule an Apex class in Salesforce?
To schedule an Apex class in Salesforce, go to Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex. In the next step, enter the name of a class that you want to schedule. Specify how often the Apex class is to run. For Weekly—specify one or more days of the week the job is to run (such as Tuesday).


Batch Apex in Salesforce

To use batch Apex in Salesforce, users need to write an Apex class that implements the Salesforce-provided interface Database.


Insert attachment in apex Salesforce

To insert an attachment in apex Salesforce, you need to write this code:

public void saveAttachment(){
  String encodedContentsString = System.currentPageReference().getParameters().get('fileContents');
  Id accountId = System.currentPageReference().getParameters().get('accountId');
  Attachment attachment = new Attachment();
  attachment.Body = Blob.valueOf(encodedContentsString);
  attachment.Name = String.valueOf('test.txt');
  attachment.ParentId = accountId; 
  insert attachment;

Create an email template using Apex Salesforce

To send email using a template in apex salesforce, please do:
Go to Setup-> search ‘template’ -> choose ‘Classic Email Templates’-> click on ‘New Template’ button.
Select the Visualforce option for ‘type of email template.’
Enter the template name, keep the other defaults. …
Enter Email Subject text.

Apex sharing in salesforce

Users with “Modify All Data” permission can add or change Apex managed sharing on a record. Apex sharing enables developers to programmatically manipulate sharing to support their behavior through Apex or the SOAP API. This type of sharing is similar to managed sharing.

Inflation Is Eating IRA/401(k) Savings! How to Protect Your IRA/401(k) in Bad Times?


Recent Posts