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

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ค. 2022
  • #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 ปีที่แล้ว +1

    very nice explanation sir

  • @sheetalsharma1675
    @sheetalsharma1675 3 หลายเดือนก่อน +1

    super sir

  • @srinivasreddy3657
    @srinivasreddy3657 3 หลายเดือนก่อน +1

    Great explanation with simple words.More people need to know about this channel.

    • @SalesforceGyaan
      @SalesforceGyaan  3 หลายเดือนก่อน

      Thanks Please Do Like Share and Subscribe

  • @srinivasreddy3657
    @srinivasreddy3657 3 หลายเดือนก่อน +1

    Great explanation sir.People need to know about this channel

    • @SalesforceGyaan
      @SalesforceGyaan  3 หลายเดือนก่อน

      Thanks, Please Do Like, Share and Subscribe

  • @akashdhargave3314
    @akashdhargave3314 8 หลายเดือนก่อน

    Good Information ❤

  • @SalesforceGyaan
    @SalesforceGyaan  ปีที่แล้ว +1

    *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/