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
SunchaserSunchaser 

Trigger problem

Hi,

 

I am new with Apex, I wrote the following code..  Normally this code compares the myset set values with the BillingPostalCode field and if they match it updates the field (change my custom field "locality" to "Philadelphia") . This code works, if the field it is updating is a default Account field. For example it changes Account Name field without any errors but it doesn't update my custom field.   Is there an extra step needed for custom fields that I created? 

 

I would really appreciate if anyone can tell me what is the problem..

 

Thanks!

 

   

 

trigger testtrigger on Account (Before insert, before update) {
//populate set
Set<String> myset = new Set<String>{'08759','08757','08753','08721','08731','08758'}; 
//iterate through Trigger.new
    for(Account A : Trigger.new){
//Check if Account field is in myset
        if(myset.contains(A.BillingPostalCode){

            A.Locality= 'Philadelphia';
        }  
    }   
}

 

Best Answer chosen by Admin (Salesforce Developers) 
BylithiumBylithium

I did try the code with the custom field...It is working perfectly fine

There are no additional changes for custom field..its the same process

All Answers

BylithiumBylithium

I did try the code with the custom field...It is working perfectly fine

There are no additional changes for custom field..its the same process

This was selected as the best answer
SunchaserSunchaser

Hey, you're right! Seems like the problem I was experiencing was unrelated with this..

Thanks for your answer Bylithium.