• Steven Berg 10
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi Experts, 

am trying to read values from few fields (text and dropdown fields)in a before insert Account trigger.
but to my surprise, when am trying to read values from drop down fields am getting null values while inserting a record. but inserted record has valid values in drop down lists.
but while updating a record it looks fine

below is the code, 
trigger assignLocation on Account (before Insert, before Update) {
 for (Account account : Trigger.new) {
        street.add(account.ShippingStreet);
        city.add(account.ShippingCity);
        state.add(account.ShippingState);
        zipCode.add(account.ShippingPostalCode);
        country.add(account.ShippingCountry);
     } 
}
     
     System.debug('--streetstreet --: ' + street ); // am getting desired value
     System.debug('--citycity --: ' + city ); // am getting desired  value
     System.debug('--statestate --: ' + state ); // this is drop down field, in trigger it shows null while inserting a record.
      System.debug('--zipCode --: ' + zipCode ); // am getting desired  value
     System.debug('--countrycountry --: ' + country ); // this is drop down field, in trigger it shows null while inserting a record.



I have to use BEFORE INSERT/UPDATE TRIGGER, as i have to update a field before inserting.

Thank you
  • September 17, 2015
  • Like
  • 0