penone
penone

Reputation: 792

In Netsuite - How can I move a country to the top of the list?

In Netsuite I would like to have the United States and Canada moved to the top of the country list. Is there a way to achieve this?

Upvotes: 0

Views: 157

Answers (1)

Skromak
Skromak

Reputation: 560

If you are using a SuiteScript 2.0 Suitelet with a Form you can source the country list like this:

var custRec = record.create({ type: record.Type.CUSTOMER, isDynamic: true });
var custSubrec = objRecord.getCurrentSublistSubrecord({ sublistId: 'addressbook', fieldId: 'addressbookaddress' });
var countryFieldObj = objSubrecord.getField({ fieldId: 'country' });
var countryList = countryFieldObj.getSelectOptions();

Then create the field and insert the countries

var countryField = form.addField({ id: 'custpage_country', type: 'select', label: 'Country' });

// Add the US and CA first

for (var i = 0; i < countryOptions.length; i++) {
    if (countryOptions[i].value === US || countryOptions[i].value === CA) {       
      countryField.addSelectOptions({
        value : countryOptions[i].value,
        text : countryOptions[i].text
      });
   }
}

// Then add the rest of the countries in after

for (var i = 0; i < countryOptions.length; i++) {
    if (countryOptions[i].value !== US || countryOptions[i].value !== CA) {       
      countryField.addSelectOptions({
        value : countryOptions[i].value,
        text : countryOptions[i].text
      });
   }
}

I hope this helps!

Upvotes: 1

Related Questions