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
Sébastien BeaulieuSébastien Beaulieu 

Do someone know how to add States in Metadata States PickList from code

When I try to add a new Account by using RestAPI and the BillingStateCode does not exists in the metadata State PickList we receive a error. 

Is it possible to Add with Apex Code missing State in the metadata State PickList ?

Thanks
 

 

VinayVinay (Salesforce Developers) 
Hi,

You can use the Metadata API to edit existing states and countries in state and country picklists. You can’t use the Metadata API to create or delete new states or countries.

Review below idea link for same.

https://trailblazer.salesforce.com/ideaView?id=08730000000l6DGAAY

Few references  that can help you
https://salesforce.stackexchange.com/questions/20755/how-to-mass-populate-state-country-picklist-values
https://salesforce.stackexchange.com/questions/269708/can-anyone-tell-me-how-to-get-state-country-picklist-values-metadata-api?rq=1

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
PkPk
I can't figure it out, do you have a solution for this:
 
It is required to create a Flow that allows the ACCOUNT object to be updated with the weather if a city in India is selected.
 
 It is required to allow the user to select a country in Flow from a list of countries and a city from that selected country.
 
 As soon as it is recognized that it is the country of India, the city must be updated in the custom field in the ACCOUNT object. If it is not India, there is no need to update the field.