Reputation: 413
I am using SuiteScript 2.0 in Netsuite. The list of countries are available in Setup > Company > Countries. As of current version, I have not found a way to get list of Countries and State/Province drop downs added in custom Suitelets.
How Can I access this list from Netsuite Suitescripts?
Upvotes: 2
Views: 6184
Reputation: 560
There could be a more direct way to do this, but you can begin creating a customer record, access the address object and get the select options that are available.
var custRec = record.create({ type: record.Type.CUSTOMER, isDynamic: true });
var custSubrec = custRec.getCurrentSublistSubrecord({ sublistId: 'addressbook', fieldId: 'addressbookaddress' });
var countryFieldObj = custSubrec.getField({ fieldId: 'country' });
var countryList = countryFieldObj.getSelectOptions();
Upvotes: 3
Reputation: 11
Create a Saved Search for customer Record named customsearch_customercountry
where criteria is empty and Results contains the fields you want (including country by example). The saved search will be loaded and include the filter using the customerId as variable taken or filled from your code previous sentences.
the script will be as:
var country_search = search.load({
id: "customsearch_customercountry",
});
var filterArray = [];
filterArray.push(["internalid", "is", customerId]);
country_search.filterExpression = filterArray;
var searchResult = country_search.run().getRange({
start: 0,
end: 1,
});
log.debug({
title: "Execute Search ",
details: "ResultSet length: " + searchResult.length,
});
if (searchResult.length > 0) {
var country = searchResult[0].getText({
name: "Country",
});
log.debug({
title: "Execute Search ",
details: "ResultSet found with country: " + country,
});
}
NOTE: you must use the .getText()
function to retrieve the text value for the country Result. If you only need the Country code, use .getValue()
instead of
Upvotes: 1
Reputation: 8857
There is no module or enumeration anywhere for this. SuiteScript uses the ISO-standard two-letter (ALPHA-2) country codes. http://www.nationsonline.org/oneworld/country_code_list.htm
Upvotes: 2