Trying to get the internal id for a newly created ...
# suitescript
r
Trying to get the internal id for a newly created address book entry on a customer record in order to pass it to a sales order.
Copy code
newCustomerRecord = Nrecord.load({
                type: Nrecord.Type.CUSTOMER,
                id: newCustomerIID,
                isDynamic: false,
            });

            let newAddressBookEntry = newCustomerRecord.getSublistSubrecord({
                sublistId: uvLibID.field.CUSTOMER.sublist.ADDRESS_BOOK.id,
                fieldId: uvLibID.field.CUSTOMER.sublist.ADDRESS_BOOK.ADDRESS_BOOK_RECORD,
                line: newAddressLineID,
            });
            Nlog.debug({title: 'createCustomer', details: JSON.stringify(newAddressBookEntry)});
            Nlog.debug({title: 'createCustomer', details: JSON.stringify(newAddressBookEntry.id)});
the first debug line is properly outputting the address record. however when I tr to access
newAddressBookEntry.id
, I'm getting
null
.
e
1. When passing an Object as the
details
in any
log
method, there's no need to explicitly call `JSON.stringify`; that is implicitly done for you by the module. 2.
newAddressBookEntry.id
is not a valid JSON string; it's a scalar string. You should just be able to pass
details: newAddressBookEntry.id
r
thanks, but changing debug logging style doesn't change that
newAddressBookEntry.id
is still null, even though NetSuite says it should be populated with the internal id of the address book record
c
r
hm... okay, so my approach is obviously wrong. What would be the correct approach to get the internal ID of an address book record from a customer record, in order to set it on the shiptoseelct on a sales order?
found my answer. thanks for the push!