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
Juan Miguel FranciaJuan Miguel Francia 

IsInsert and IsUpdate Trigger Question

Juan Miguel FranciaJuan Miguel Francia

I need to create a trigger validation where in I am comparing object 1 to the record of obj 2. What I need to do is to be able to return the functional currency available based on what I selected in object 1. This is the code I created so far. 

 

public static void GEandMCevaluation(List<Matter__c> MatterList)
    {
        Set<String> countryMatter = new Set<String>();
        Set<String> GoogleEntity = new Set<String>();	
        
        
        //capture Current google entity and current matter country
        for(Matter__c mat : MatterList ){
            countryMatter.add(mat.Matter_Country_Countries__c);
            GoogleEntity.add(mat.Google_Entity__c);
        }
        
        //query the captured google_entity__c and current_matter_country__c
        List<Matter_Entity_Currency_Schedule__c> listofentitiycountrycurrencies = 
            [Select Functional_Currency__c FROM Matter_Entity_Currency_Schedule__c where Google_Entity__c IN : GoogleEntity
            AND Country__c IN: countryMatter ];
        
       
        
        
        String[] functionalCurrencies;
        
        
        if(!listofentitiycountrycurrencies.isEmpty()){
            for(Matter_Entity_Currency_Schedule__c mescs : listofentitiycountrycurrencies){
                
                functionalCurrencies = mescs.functional_currency__c.split(';');
            }
        }
        
        String displayEligibleCurrencies = '';
        
        for(String s :functionalCurrencies){
            // concatenate each eligible currency to the string buffer
            displayEligibleCurrencies += s;
        }
        
        
        System.debug(displayEligibleCurrencies);
        
        
        
    }
Harish RamachandruniHarish Ramachandruni
Hi,

Read this document https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm
 
trigger.isInsert is true when a new record is created and inserted.

trigger.isUpdate is true when an existing record is modified.

Example:

trigger memberInviteNotify on Member__c (after insert,after update)
{

        if(trigger.isInsert)
        {
        // When a new record is created and inserted, the flow will come here
        ............................
        ............................
        ............................ 
        }
        
        if(trigger.isUpdate)
        {

        // When an existing record is modified, the flow will come here
        ............................
        ............................
        ............................
        }

}


Any issue ask me at harish.rao.salesforce@gmail.com


Regards,
Harish.R
Juan Miguel FranciaJuan Miguel Francia
The code I written is a trigger handler. I forget to include it in my question. Thanks for the reply.