Trigger.New ,Trigger.NewMap, Trigger.old and Trigger.oldmap |Context Variable | Salesforce Gyaan

  Рет қаралды 4,613

Salesforce Gyaan

Salesforce Gyaan

2 жыл бұрын

#salesforce #salesforcedevelopers #salesforceadmin #salesfunnelstrategy #apextrigger
#apex #apextraining #salesforcetraining #apexlegends #development #salesforcetutorial
What are the different context variables used with Different Events in Apex Triggers?
Apex can be invoked by using triggers. Apex triggers enable you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions.
A trigger is Apex code that executes before or after the following types of operations:
insert
update
delete
merge
upsert
undelete
You can define triggers for top-level standard objects that support triggers, such as a Contact or an Account, some standard child objects, such as a case comment, and custom objects. To define a trigger, from the object management settings for the object whose triggers you want to access, go to Triggers.
There are two types of triggers:
Before triggers are used to update or validate record values before they’re saved to the database.
After triggers are used to access field values that are set by the system (such as a record's Id or LastModifiedDate field), and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue. The records that fire the after trigger is read-only.
trigger TriggerName on ObjectName (trigger_events) {
code_block
}
The code block of a trigger cannot contain the static keyword. Triggers can only contain keywords applicable to an inner class. In addition, you do not have to manually commit any database changes made by a trigger.
If your Apex trigger completes successfully, any database changes are automatically committed. If your Apex trigger does not complete successfully, any changes made to the database are rolled back.
The record firing a trigger can include an invalid field value, such as a formula that divides by zero. In this case, the field value is set to null in these variables:
new
newMap
old
oldMap
For example, in this simple trigger, Trigger.new is a list of sObjects and can be iterated over in a for loop. It can also be used as a bind variable in the IN clause of a SOQL query.
Trigger simpletrigger on Account (after insert) {
for (Account a : Trigger.new) {
// Iterate over each sObject
}
// This single query finds every contact that is associated with any of the
// triggering accounts. Note that although Trigger.new is a collection of
// records, when used as a bind variable in a SOQL query, Apex automatically
// transforms the list of records into a list of corresponding Ids.
Contact[] cons = [SELECT LastName FROM Contact
WHERE AccountId IN :Trigger.new];
}
========================================================================
🔔 Subscribe and Stay Tuned:
Make sure to subscribe to "Salesforce Gyaan" for more tutorials on web development, programming, and technology. Hit the bell icon to receive notifications when we upload new content.
🤝 Connect with Us:
Facebook: salesforceGyaan
LinkedIn: linkedin.com/in/prashant-sontakke-75b758126
Website: www.salesforcegyaan.com
Contact: 7020694830
🙌 Join Our Community:
Have questions or want to discuss the tutorial? Join our WhatsApp community: chat.whatsapp.com/D6vpTSF57rB...
#JavaScript
#SalesforceDevelopment
#WebDevelopment
#JavaScriptTutorial
#SalesforceTutorial
#Coding
#Programming
#FrontEndDevelopment
#SalesforceCRM
#WebDev
#JavaScriptDevelopment
#SalesforceAdmin
#DeveloperTips
#SalesforceIntegration
#CodeLearning
#TechTutorial
#SalesforceApex
#JavaScriptFrameworks
#SalesforceLightning
#CodingTips
#SalesforceAppDevelopment
#LearnJavaScript
#SalesforceTrailhead
#HTML
#CSS
#LWC
#SalesforceLWC
#LightningWebComponents
#SalesforceDevelopment
#SalesforceLightning
#WebComponents
#SalesforceDX
#SalesforceDeveloper
#LWCTutorial
#SalesforceApex
#WebDevelopment
#SalesforceCRM
#LightningExperience
#SalesforceAdmin
#SalesforceAppDevelopment
#SalesforceIntegration
#AuraComponents
#SalesforceTrailhead
#FrontEndDevelopment
#LightningDesignSystem
#SalesforceCustomization
#SalesforceCode
#SalesforceTips
#ApexProgramming
#SalesforcePlatform
#Salesforce
#LWC (Lightning Web Components)
#SalesforceDevelopment
#SalesforceTutorial
#SalesforceAdmin
#LWCTutorial
#LWCDevelopment
#SalesforceApex
#SalesforceIntegration
#SalesforceCRM
#SalesforceTrailhead
#SalesforceBeginner
#SalesforceAdvanced
#LWCComponents
#SalesforceDeveloper
#SalesforceAutomation
#SalesforceLightning
#LWCBasics
#SalesforceAppBuilder
#SalesforceCustomization

Пікірлер: 10
@rage3072
@rage3072 Жыл бұрын
very nice explanation sir
@SalesforceGyaan
@SalesforceGyaan Жыл бұрын
Thank you
@sheetalsharma1675
@sheetalsharma1675 3 ай бұрын
super sir
@srinivasreddy3657
@srinivasreddy3657 3 ай бұрын
Great explanation sir.People need to know about this channel
@SalesforceGyaan
@SalesforceGyaan 3 ай бұрын
Thanks, Please Do Like, Share and Subscribe
@srinivasreddy3657
@srinivasreddy3657 3 ай бұрын
Great explanation with simple words.More people need to know about this channel.
@SalesforceGyaan
@SalesforceGyaan 3 ай бұрын
Thanks Please Do Like Share and Subscribe
@akashdhargave3314
@akashdhargave3314 9 ай бұрын
Good Information ❤
@SalesforceGyaan
@SalesforceGyaan 9 ай бұрын
Thanks
@SalesforceGyaan
@SalesforceGyaan Жыл бұрын
*Dear Salesforce Learners stay tune for more videos - Salesforce Gyaan* For more details stay tuned to Salesforce Gyaan To get to know about our upcoming batches Mail us: prashinfo19@gmail.com LinkedIn: www.linkedin.com/feed/ Facebook : facebook.com/salesforceGyaan/
Basics Of Salesforce Development
36:00
Salesforce Gyaan
Рет қаралды 969
Trigger New Vs Trigger New Map || By Rajesh Chatterjee
9:00
Cool Items! New Gadgets, Smart Appliances 🌟 By 123 GO! House
00:18
123 GO! HOUSE
Рет қаралды 17 МЛН
Does size matter? BEACH EDITION
00:32
Mini Katana
Рет қаралды 20 МЛН
Самый Молодой Актёр Без Оскара 😂
00:13
Глеб Рандалайнен
Рет қаралды 6 МЛН
100❤️
00:19
MY💝No War🤝
Рет қаралды 23 МЛН
Apex Trigger Framework
20:37
Salesforce Decoder
Рет қаралды 1,3 М.
Trigger Context Variables || By Rajesh Chatterjee
15:33
Delipat
Рет қаралды 2,7 М.
A journey of salesforce Developer @salesforcejungle
47:26
Mr Seeker
Рет қаралды 15 М.
Context Variable & it's types with example- Part 1 [Hindi] - Chapter 19
11:13
Apex Triggers - 47 (Accenture Interview Scenario)
13:51
SFDC Ninja
Рет қаралды 6 М.
Cool Items! New Gadgets, Smart Appliances 🌟 By 123 GO! House
00:18
123 GO! HOUSE
Рет қаралды 17 МЛН