Anyone know a good way to get a list of the Countr...
# suitescript
j
Anyone know a good way to get a list of the Countries (and ids) in Suite Script? Suite Answer 63281 suggests making a custom record type just to be able to use getSelectOptions() which is obviously an insane approach. I'd rather not hard-code the list.
d
@jen I ended up creating a module with those hard coded values
j
Yeah that's the route I'm going with currently
d
I think i ran a client script to extract name, id, and abbrev.
then i made some helper functions search and such
s
Sadly, from past discussion here, I think hard-coding is what most people end up doing, as there really isn't a built-in API for countries. The NFT toolkit uses that approach: https://github.com/ExploreConsulting/netsuite-fasttrack-toolkit-ss2/blob/master/geography.js One good thing is that the country ids are the same as the ISO 3166-1 alpha-2 country codes, so you can use any list, library, or resource that provides them. We use the ICU (http://site.icu-project.org/) project's JSON file as a source for this data. That file is shared with other JS applications outside of NetSuite as well, which is why we prefer it, but any up to date resource should work.
j
It's RIDICULOUS that there's no way to get a basic list from the database....
oh NS
b
only thing to watch out for is that fields using the custom country as the source use internal id numbers instead of the 2 letter code
j
....... 😞
Imma make a module with ID/Lettercode/Name
e
I recently had to create modules for States and Countries as well
Untitled
d
@erictgrubaugh maybe throw those into a gist?
s
that NFT link above has ID/abbreviation/name for a pretty broad list across countries and states. It would be awesome for people to improve it rather than recreate the wheel.
1000 1
e
It's not recreating the wheel if you don't use NFT
💯 1
s
You can just take that file and use it directly, as @scottvonduhn mentioned. It doesn't have any "NFT" magic.