am trying to read values from few fields (standard shipping address text and dropdown fields in Account object)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 shows valid values in drop down lists.

while updating a record it works as expected

below is my code,

trigger [assignLocation] on Account (before Insert, before Update) {
 for (Account account : Trigger.new) {

     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 debugging when 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.

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

Thank you

  • There appears to be code missing from your trigger. Where are street, city, state, zipCode and country list variables defined at in your trigger and why are you adding the values from trigger.new to them? I assume they must be lists since your adding values to them from trigger.new.
    – crmprogdev
    Commented Sep 18, 2015 at 18:54

1 Answer 1


Since State is a picklist, I am guessing that you have State and Country picklists enabled. If that is the case, then you should use ShippingStateCode and ShippingCountryCode in your trigger.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .