function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
salesforce studysalesforce study 

triggers

"System.Trigger.new"   what is mean by this ,whether creating a new trigger or somwthing else

SFAdmin5SFAdmin5

trigger.new is a list of the new instances of a class i think.  i believe someone else can provide a better definition.

Andrew WilkinsonAndrew Wilkinson

When objects are passed into a trigger it is added to a list which is Trigger.new. The objects in the list have the most recent changes to the fields. Trigger.old is the same list of objects but it has the previous values of the object before the most recent edits were done.

 

So for example if you changed the account name from Acme Corportation to Walt Disney. THe account would be added to two lists the Trigger.new list and the trigger.old list. In the trigger.new list the name would be Walt Disney. In the Trigger.old list the name would be Acme Corporation.

salesforce studysalesforce study

thank u for replying and i'l post my my controller code and trigger code

 

visualforce:

<apex:page controller=" transfer">

 <apex:pageBlockSection >
           <apex:outputField value="{!send.Benifitiary_Name__c}" /> <br/>       
           <apex:inputfield value="{!send.Amount__c}"/>  
          </apex:pageBlockSection>

 </apex:pageBlockSection >

</apex:page>

 

controller:

 

public transferingpage(){
         confirm1();
        Id id = ApexPages.currentPage().getParameters().get('id');
        send = (id == null)? new Fund_Transfer__c():[SELECT Id,Amount__c,Account_No__c,Benifitiary_Name__c FROM Fund_Transfer__c ];    
    }

 

public PageReference transfered() {
            Fund_Transfer__c displayrecords = [SELECT id,Amount__c,Account_No__c,Benifitiary_Name__c FROM Fund_Transfer__c WHERE Benifitiary_Name__c =: picklist];
            update send;
            return null;
    }

 

trigger:

 

Trigger updateamount on Fund_Transfer__c (before insert,before update) {
 List<Fund_Transfer__c> transferlist = new List<Fund_Transfer__c>();
    for(Fund_Transfer__c transfer : trigger.new){
             
           for(Fund_Transfer__c tansferingamount : [SELECT id,Amount__c,Benifitiary_Name__c FROM Fund_Transfer__c WHERE Id =: transfer.id ]){            
                 tansferingamount.Amount__c =  transfer.Amount__c + tansferingamount.Amount__c;
              
           }         

    }        
}

 

i need to update my custom object(Fund_Transfer__c) like i'l get the Two fields from the visual force page one is Benefitiary_Name__c and the other is Amount__c ,

 

if I enter the  Benefitiary_Name__c in the visual force page which is in the custom object

first it must find the record of enterd Benefitiary_Name__c and Amount__c  and in the particular record the entered amount must be  added to the same recorde as update.

 

so these are all must be done in triggers.

 

this is my great dought.

 

 

salesforce studysalesforce study

thank you for describing me About trigger.new and trigger.old

can you  give some examples in triggers to insert and update bulk datas in single objects,please