Trigger.newMap in APEX Trigger

  This variable returns a map of ids to the new versions of sObject records. Note: This map is only available in before update, after insert, after update and after undelete triggers. trigger ApexTrigger on Account(before update { Map < Id, Account > nMap = new Map < Id, Account > (); nMap = Trigger.newMap; List […]

Trigger.old of Apex Trigger

This variable returns a list of the old version of sObject records. This list is only available in update and delete triggers trigger ApexTrigger on Opportunity(before update) { // Only available in Update and Delete Triggers for (Opportunity oldOpp: Trigger.old) { for (Opportunity newOpp: Trigger.new) { if (oldOpp.Id == newOpp.Id && oldOpp.Amount != newOpp.Amount) newOpp.Amount.addError(‘Amount […]

Understanding Lookup Relationships in Salesforce: A Step-by-Step Guide

What is a Lookup Relationship? A Lookup Relationship in Salesforce is a loose association between two objects, allowing you to create links between records in a way that is more flexible than a Master-Detail Relationship. In a Lookup Relationship, the child record can exist independently of the parent. This makes Lookup Relationships ideal when there […]

Factors that Affect Data Access

Some factors affect access to your organization’s data. When using the API, the following factors affect access to your organization’s data: Access Object-Level and Field-Level Security Sharing User Permissions User Permissions that Override Sharing Objects properties Related Objects Page Layout and Record Types Acces Your organization must be enabled for API access.Objects may not be […]

Trigger.new of Apex Triggers

This variable returns a list of the new version of sObject records. This list is only available in insert, update, and undeletes triggers.Example:- t trigger ApexTrigger on Account(before insert) { for (Account acc: Trigger.new) { acc.NumberOfEmployees = 100; } }

Context Variables of Apex Triggers

Apex Triggers have access to several context variables that provide information about the trigger event and the records involved. These context variables are automatically provided by Salesforce and can be used within the trigger code to perform various operations. These context variables provide a lot of information about the trigger event and can be used […]

Trigger Events in Salesforce

There are multiple apex trigger events for both before & after context DML  –before insert– after insert– before update– after update– after undelete– before delete– after undelete

Types of Apex Triggers in Salesforce

There are two types of Triggers in Salesforce: trigger BeforeTrigger on Account(before insert) {   System.debug (‘before insert.’);   } Trigger AfterTrigger on Account(after insert) {     System.debug(‘after insert.’); }

Types of Apex Triggers in Salesforce

There are two types of Triggers in Salesforce: trigger FirstTrigger on Account(before insert) { System.debug(‘I am before insert.’); } Trigger SecondTrigger on Account(after insert) { System.debug(‘I am after insert.’); }

What is the Salesforce Apex Trigger?

In Salesforce, ApexTrigger is a piece of code that is used to execute custom business logic before or after certain events occur on records in a Salesforce database. Where1. TriggerName – The Name of the ApexTrigger2. ObjectApiName – The API Name of the Object3. TriggerEvents – The Trigger events could be any of the following(before, after) trigger TriggerName on ObjectName(trigger_events) { […]