I am editing an address like so: ```var addrSubRec...
# suitescript
g
I am editing an address like so:
Copy code
var addrSubRec = context.newRecord.getSubrecord('shippingaddress')
addrSubRec.setValue('dropdownstate', lState)
in a beforeSubmit script. It saves on the order, but it doesn't display the saved address or save to the address book for the next time that address is used. What do I have to do?
b
you probably want to be using
state
instead of
dropdownstate
beyond that, the shippingaddress subrecord is equivalent to the custom address on the transaction
you need to add the address to the
addressbook
sublist on the customer to use the same address on multiple transactions
g
@battk for some reason no matter what method i try getting Cannot find function selectNewLine in object standard record. (select new line to be replaced with save or commit or any other action) how can i set it on the context.newrecord?
and im i am in a before submit function then shouldn't just setting the address be enough?
b
Basic answer is that a record that is not in dynamic mode doesnt have selectNewLine
You just use setSublistValue on the line you want to set
You also probably need to explain what you want to do in greater detail
I described to you a method to add an addressbook line to a customer so you could use it on the sales order
That process would not involve adding a line to a sales order
g
Sublist and Subrecord are the same? I am validating the address and making changes to the City/Zip/State which are not reflecting on the Sale for some reason
b
sublists and subrecords are not the same thing
the address subrecord on a transaction represents the custom address of that transaction
changes to that address only affect that particular transaction
and making changes in a before submit tends to not update the address text on the transaction itself, so you usually need to do something to change it manually
if you want to make changes to the address from the customer record, then you dont make the changes to the address of the transaction
instead you make it on the addresbook sublist of the customer
each line of the addressbook sublist has an address subrecord, which is the subrecord you would need to modify
mandatory reading if you want to understand how to work with address subrecords
g
Thanks! I was under the impression that the error was because I was working with the newrecord
b
the newRecord does not have selectNewLine, you also shouldnt be trying to use it in the first place
g
Apparently I am missing something somwhere
var customer = record.load({
        type: record.Type.CUSTOMER,         id: context.newRecord.getValue({ fieldId: 'entity' }),         isDynamic: true       })       logDebug('Got the Customer', customer)       customer.selectNewLine({         sublistId: 'addressbook'       })       logDebug('loaded addressbook')       var addressSubrecord = customer.getCurrentSublistSubrecord({         sublistId: 'addressbook',         fieldId: 'addressbookaddress',         line: 0       })       log.debug('got address subrec', addressSubrecord)       addressSubrecord.setValue({         fieldId: 'city',         value: capitalizeFirstLetter(lCity.toLowerCase())       })       addressSubrecord.setValue({         fieldId: 'state',         value: lState       })       addressSubrecord.setValue({         fieldId: 'zip',         value: lZip       })       logDebug('set the values')       customer.commitLine({         //probably not necessary since address is already updated         sublistId: 'addressbook'       })       log.debug('committed the address on the customer') How do I load the address being used on the sale and edit that one?
b
still dont know what you are trying to do, so you get limited generic help from me
Scripting Transaction Shipping and Billing Addresses if you want to modify the custom address Updating an Address Subrecord if you want to modify the address from a customer
212 Views