Eric Schultz
03/13/2025, 11:37 PMCeligo AI
03/13/2025, 11:37 PMAI generated answer (using internal Slack threads):Based on the conversations, it appears that there isn't a direct way to access the country enum in SuiteScript. However, there are a few workarounds that have been suggested: 1. One way is to create a record and check the available select options to get the two-digit alpha code. However, this method does not provide a way to retrieve the numeric internalid. Here is an example of how to do this: [Link to Example](https://suitescript.blogspot.com/2017/06/fetch-country-list-country-code.html?m=1) 2. Another approach is to hardcode a lookup table or create a module with hardcoded values. This seems to be a common approach as there isn't a built-in API for countries in SuiteScript. 3. It's also mentioned that the country ids are the same as the ISO 3166-1 alpha-2 country codes, so any list, library, or resource that provides these codes can be used. 4. A more recent approach is to use SuiteQL to query the countries table. Here is a code snippet that demonstrates this:
javascript
require(['N/query'], function(query) {
function getCountryIdFromName(countryName) {
const sql = `SELECT id FROM country WHERE name = ?`;
const results = query.runSuiteQL({
query: sql,
params: [countryName]
}).asMappedResults();
return results.length ? results[0].id : null;
}
getCountryIdFromName('Australia');
});
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
03/13/2025, 11:37 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836085558
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816016078
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803582907
Celigo AI
03/13/2025, 11:37 PM