When I create a customer, if I use a UK country co...
# suitescript
d
When I create a customer, if I use a UK country code, I get the full address. If I use an Irish country code, the address doesn't get set. Is there configuration in Netsuite to do something like this or am I just seeing a very strange bug?
j
just making sure, did you set the county code and then re-populate the values? NetSuite does some goofiness with addresses because some countries (Ireland included) don't have State enumerations
and maybe can we see the block of code where you're setting the address?
d
so this is on create, and my address object (typescript) looks like this:
Copy code
export interface AddressRecord {
    addr1: string,
    addr2: string,
    addressee: string,
    city: string,
    country: string,
    zip: string,
    defaultBilling: boolean,
    defaultShipping: boolean
}
and the address upsert code looks like:
Copy code
upsertAddresses(record: record.Record, addresses: any[]): record.Record {
        
        record.selectLine({ sublistId : 'addressbook', line: 0 }); 
        let lineCount = record.getLineCount({ sublistId: 'addressbook' });

        for (let i = 0; i < lineCount; i++) {
            record.removeLine({ sublistId : 'addressbook', line: 0 });
        }        
        
        for (let address in addresses) {

            log.debug('record object selectNewLine', { item: record });
            record.selectNewLine({ sublistId : 'addressbook' });

            let addList = record.getCurrentSublistSubrecord({ sublistId : 'addressbook', fieldId : 'addressbookaddress' });
            
            for ( let key in addresses[address]) {
                addList.setValue({ fieldId : key, value : addresses[address][key] });
            }
            
            record.selectNewLine({ sublistId : 'addressbook' });
            record.setCurrentSublistValue({ sublistId: 'addressbook', fieldId: 'defaultshipping', value: addresses[address]["defaultShipping"] });
            record.setCurrentSublistValue({ sublistId: 'addressbook', fieldId: 'defaultbilling', value:  addresses[address]["defaultBilling"] });                        

            record.commitLine({ sublistId : 'addressbook' });
        }                

        return record;
    }
u
when creating address using script, always make sure that the country would be set first. Mainly because the forms might reset specially that some countries as configured in the address different from another one. You could have a simple if statement to not set the country while on the iteration on the keys on you object and just set it beforehand
d
interesting. thanks @クリスピポテト, I'll explore this idea.
This worked by the way, @クリスピポテト It was an ordering issue. Country code comes first and it works.
👍 1