Handling Default Billing Address in NetSuite with SuiteScript

This topic explains how to retrieve and manage the default billing address from a customer record in NetSuite using SuiteScript. The script checks whether the default billing address is set and, if not, falls back to using the first address in the address book sublist.

Finding the Default Billing Address Line:

Use the findSublistLineWithValue method to search the addressbook sublist for the line where the defaultbilling field is set to true. This helps identify the correct line number where the default billing address is stored.
 var lineNumber = custRec.findSublistLineWithValue({
                        sublistId: 'addressbook',
                        fieldId: 'defaultbilling',
                        value: true
                    });


                    if (lineNumber != -1) {
                        // LOAD ADDRESS SUBRECORD IN CUSTOMER
                        var addressSubRec = custRec.getSublistSubrecord({
                            sublistId: "addressbook",
                            fieldId: "addressbookaddress",
                            line: lineNumber
                        });
                    } else {
                        // LOAD ADDRESS SUBRECORD IN CUSTOMER
                        var addressSubRec = custRec.getSublistSubrecord({
                            sublistId: "addressbook",
                            fieldId: "addressbookaddress",
                            line: 0
                        });
                    }

Leave a comment

Your email address will not be published. Required fields are marked *