Loading

Retrieve Standard Countries and accompanying States/Territories via the Metadata API

Date de publication: Oct 1, 2024
Description

The Standard Countries list is provided in the article below:

Standard Countries and Territories for Address Picklists

However, this does not provide the states associated with each country.

We can use Metadata API to pull the Standard Countries list along with the states related to them.

 

Résolution

1) Create a sample package.xml as below :

<?xml version="1.0" encoding="UTF-8"?>
    <version>46.0</version>
    <types>
        <members>Address</members>
        <name>Settings</name>
    </types>
</Package>
 
2) Use the above package.xml in the Manifest file in the VS Code. Then right click on the Manifest file and select "SFDX: Retrieve Source in Manifest from Org"   
 
3) A new folder called "settings" is created under the force-app\main\default section.
 
4)  The file "Address.settings-meta.xml" under settings folder would display all the Countries and their accompanying state values in the VS Code as below :
 

 

Ressources supplémentaires

Metadata API guide for State/Country Picklist

 

Numéro d’article de la base de connaissances

002233551

 
Chargement
Salesforce Help | Article