var currentRecord = scriptContext.currentRecord; var addressObj = {}; var billToId = currentRecord.getValue('parent'); var recordBillTo = record.load({ type: record.Type.CUSTOMER, id: billToId, isDynamic: true, }); var addressLine = recordBillTo.findSublistLineWithValue('addressbook', 'defaultbilling', true); recordBillTo.selectLine('addressbook', addressLine); addressSubrecord = recordBillTo.getCurrentSublistSubrecord('addressbook','addressbookaddress'); addressObj.addressee = addressSubrecord.getValue('addressee'); addressObj.address1 = addressSubrecord.getValue('addr1'); addressObj.country = addressSubrecord.getValue('country'); addressObj.city = addressSubrecord.getValue('city'); addressObj.dropdownstate = addressSubrecord.getValue('dropdownstate'); addressObj.zip = addressSubrecord.getValue('zip'); addressObj.addrtext = addressSubrecord.getValue('addrtext'); createLine(currentRecord, addressObj); function createLine(record, addressObj){ record.selectNewLine('addressbook'); record.setCurrentSublistValue('addressbook', 'defaultbilling', true); record.setCurrentSublistValue('addressbook', 'label', addressObj.address1); var addressSubrecord = record.getCurrentSublistSubrecord('addressbook', 'addressbookaddress'); addressSubrecord.setValue('addressee', addressObj.addressee); addressSubrecord.setValue('address1', addressObj.address1); addressSubrecord.setValue('country', addressObj.country); addressSubrecord.setValue('city', addressObj.city); addressSubrecord.setValue('dropdownstate', addressObj.dropdownstate); addressSubrecord.setValue('zip', addressObj.zip); addressSubrecord.setValue('addrtext', addressObj.addrtext); record.commitLine('addressbook'); }