My line count correctly shows the correct number o...
# suitescript
m
My line count correctly shows the correct number of addresses on the customer record, but my log shows blank values for the fields. I am sure I have previously used something similar to this:
Copy code
const _CUSTOMER = record.load({
    type: record.Type.CUSTOMER,
    id: internal_id,
    isDynamic: true,
});
const address_count = _CUSTOMER.getLineCount({
    'sublistId': 'addressbook'
});
 for (var x = 0; x < address_count; x++) {
                const address_subrecord = _CUSTOMER.getCurrentSublistSubrecord({
                    sublistId: 'addressbook',
                    fieldId: 'addressbookaddress'
                });
                _CUSTOMER.selectNewLine({
                    sublistId: 'addressbook',
                });
                const address_internal_id = address_subrecord.getValue({
                    fieldId: 'id',
                });
                log.debug({title: "address_internal_id", details: address_internal_id});
                const address_line_1 = address_subrecord.getValue({
                    fieldId: 'addr1',
                });
                const address_city = address_subrecord.getValue({
                    fieldId: 'city',
                });
            }
b
you dont select an existing addressbook line
you only select the new line (in the wrong place), which wont have an existing address subrecord
m
I've removed this:
Copy code
_CUSTOMER.selectNewLine({
                    sublistId: 'addressbook',
                });
I can now see country code, but that's all. I should see addr1, city and other bits
b
there are 2 parts to my comments
you are missing code
and you have extra code
you removed the extra code
now add in the part where you select an existing line
m
ah, right - thanks
s
or just
Copy code
const c = new Customer(internal_id)
 _.forEach( c.addressbook, a => log.debug(a.addressbookaddress))
lodash 1