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
Frédéric ProvotFrédéric Provot 

Setting BillingState and BillingStateCode together causes both fields to be null

Hi.
A problem that appears this month in production as well as in sandboxes : If you create an account and set (unusefully) both BillingState and BillingStateCode fields (with the same entry of course), AND have a workflow or a Process Builder that updates some other field(s), then both BillingState and BillingStateCode are finally empty (null).

Step to reproduce:
  • Notice a country having some states (in State & Country picklist management).
  • Create a unit test that just insert a new account, with both BillingStateCode and BillingState fileds set. And which then read the account and display all its fields.
  • Create a workflow or a process builder that updates a field on accounts at creation.
  • Run the test.
-> the account have both BillingStateCode and BillingState fields NULL.

I set some debug logs on account trigger which tell (tracing trigger.old/trigger.new):
BEFOREINSERT : 
    the new record have BillinStateCode and BillingState set.
AFTERINSERT : 
    the new record have BillinStateCode and BillingState set.
BEFOREUPDATE : 
    the old record have BillinStateCode and BillingState set.
    the new record have BillinStateCode and BillingState set.
AFTERUPDATE : 
    the old record have BillinStateCode and BillingState set.
    the new record have BillinStateCode and BillingState UNSET (null). (NOT BY OUR CODE)
NEXT BEFOREUPDATE :
    the old record have BillinStateCode and BillingState UNSET.
    the new record have BillinStateCode and BillingState UNSET.
    
I also made tests to read the record from DB at each step, which confirm this.
So there is a problem at DB persistence time during first update.

This is just to mention as I spent a lot of hours narrowing the problem.
Regards