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
Sudhir_MeruSudhir_Meru 

Lower Case and Upper Case value in Trigger

Hi,

 

  I created a trigger to check the Billingstate. In below trigger if user enter ALABAMA it will update as AL. 

 

  What if user enter Alabama or alabama how to convert this into upper case please suggest. 

 

trigger Update_Account_BillTO_ShipTO_State on Account (Before Insert, Before Update)
{
  for (Account a : Trigger.new) 
  {
     if ( a.BillingState == 'ALABAMA' ) 
      {
         a.BillingState = 'AL';
       }     
  
 
   } 
}

 Thanks

Sudhir

Best Answer chosen by Admin (Salesforce Developers) 
Naveen NelavelliNaveen Nelavelli

trigger Update_Account_BillTO_ShipTO_State on Account (Before Insert, Before Update)
{
  for (Account a : Trigger.new)
  {
     if ( a.BillingState.toUpperCase() == 'ALABAMA' )
      {
         a.BillingState = 'AL';
       }    
 

   }
}

All Answers

Naveen NelavelliNaveen Nelavelli

trigger Update_Account_BillTO_ShipTO_State on Account (Before Insert, Before Update)
{
  for (Account a : Trigger.new)
  {
     if ( a.BillingState.toUpperCase() == 'ALABAMA' )
      {
         a.BillingState = 'AL';
       }    
 

   }
}

This was selected as the best answer
Maurice LopesMaurice Lopes
Hi,
@Naveen Nelavelli?

How would you create a trigger for the requirement below?

Add a trigger to Salesforce that automatically converts Account Email address to lower case & updates the Customer ID field with that email address.  Account Email and Customer ID fields are both located on the account page layout (Person Account).

Thanks,

Maurice