ERROR: The BillingStateCode field contains Al, which isn't an available state. Your administrator can add it for you., fields [BillingStateCode]".
Issue #1
You see the error message like this:
This error may appear if you enable the country/state picklist in your Salesforce org. This error message means the state defined in Magento doesn't exist in the Salesforce system or has a different state code.
Solution #1: Add this state in your Salesforce org:
- From Setup, enter State in the Quick Find box, then select State and Country Picklists.
- Click Configure states and countries.
- Click New Country to add a country or click Edit for a listed country.
- Under Country Information, specify your options.
- In the "States" section you can manage existing records or add new one
Issue #2
You see the error message like this:
The issue happens because the state is picklist in the Salesforce, but simple text field in your Magento. It means Magento doesn't have information about state code and send the state name to the Salesforce:
Solution #1: disable picklist in the Salesforce
- From Setup, enter State in the Quick Find box, then select State and Country Picklists.
- Click the Disable button at the bottom of the page
- Disable picklist support in our Magneto module: Salesforce → General configuration → State and Country Picklists
Solution #2: create state picklist data in your Magento:
We strongly recommend create database backup before you make any changes!
Check on the staging store copy first!
Prepare SQL script to add necessary states to the directory_country_region and directory_country_region_name tables. Here is an example for Norway:
INSERT INTO `directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL, 'NO', '01', 'Østfold'), (NULL, 'NO', '02', 'Akershus'), (NULL, 'NO', '03', 'Oslo'), (NULL, 'NO', '04', 'Hedmark'), (NULL, 'NO', '05', 'Oppland'), (NULL, 'NO', '06', 'Buskerud'), (NULL, 'NO', '07', 'Vestfold'), (NULL, 'NO', '08', 'Telemark') ; INSERT INTO directory_country_region_name( locale, region_id, name ) SELECT 'en_US' AS "language", region_id, default_name FROM `directory_country_region` WHERE country_id = 'NO'; INSERT INTO directory_country_region_name( locale, region_id, name ) SELECT 'en_US' AS "language", region_id, default_name FROM `directory_country_region` WHERE country_id = 'nb_NO'; INSERT INTO directory_country_region_name( locale, region_id, name ) SELECT 'en_US' AS "language", region_id, default_name FROM `directory_country_region` WHERE country_id = 'nn_NO';
Prepare SQL queries to update address tables. Here is an example for Norway country
UPDATE customer_address_entity SET region_id = (SELECT region_id FROM directory_country_region WHERE directory_country_region.default_name = customer_address_entity.region AND directory_country_region.country_id = customer_address_entity.country_id ) WHERE (region_id = 0 or ISNULL(region_id)) AND country_id = 'NO'; UPDATE sales_order_address SET region_id = (SELECT region_id FROM directory_country_region WHERE directory_country_region.default_name = sales_order_address.region AND directory_country_region.country_id = sales_order_address.country_id ) WHERE (region_id = 0 or ISNULL(region_id)) AND country_id = 'NO'; UPDATE quote_address SET region_id = (SELECT region_id FROM directory_country_region WHERE directory_country_region.default_name = quote_address.region AND directory_country_region.country_id = quote_address.country_id ) WHERE (region_id = 0 or ISNULL(region_id)) AND country_id = 'NO';
- Apply these patches on your staging installation first.
Related articles