Hey all - I'm trying to edit a shipping subrecord ...
# suitescript
t
Hey all - I'm trying to edit a shipping subrecord on a sales order. The code I am using is nlapiEditSubrecord('shippingaddress'), but it's returning nothing. I'm not sure if I'm using the wrong field name or if it's something else. Any advice would be awesome
l
I don't think your syntax is correct. Might need to cross check in SuiteAnswers the correct one. Just search 'address subrecord script'. Sorry I am using mobile hence couldn't check.
p
var address = rec.createSubrecord('shippingaddress'); address.setFieldValue('city'); rec.commitSubrecord('shippingaddress'); Try this. Here rec object is from SO.
r
Yup, its correct. the intrenalid for address subrecord is 'addressbookaddress'
t
Thanks everyone for the replies.
@prasad I'm trying to edit an existing address subrecord on a new sales order. @Ravi When I use addressbookaddress as the fieldname for the editSubrecord function, Netsuite throws this error "Field addressbookaddress is not a subrecord field."
r
may i know which field you want to edit on the shippingaddress subrecord?
t
What I am trying to do is get the state off the address subrecord
shippingaddress subrecord*
p
in that case, try this rec.editSubrecord('shippingaddress').getFieldValue('addrtext'); rec.setFieldValue ('shippaddress', addrtext); But using this we will get all address as string. If it is not working, better to use customer record to load all the addresses.
t
@prasad when I use rec.editSubrecord('shippingaddress').getFieldValue('addrtext'), Netsuite throws an error saying it can't get field value of null 😞
p
instead of addrtext, use state we will get the state itself
t
Same issue
It seems the issue is it isn't pulling in the address Subrecord for whatever reason
p
Try using this code in Debugger, and see the record and subrecord object var sorec = nlapiLoadRecord('salesorder', 111); var state = sorec.editSubrecord('shippingaddress').getFieldValue('state'); Generally it should work on salesorder type.
t
I wonder if the issue is because it's a new sales order?
r
Is this problem solved now?
t
Not yet 😞
r
Send me the screen shot salesorder shipping tab
t
I figured out the issue. On the shipping tab, it gives the option to use a stored address or enter a custom address. When I use a stored address, I can't access the subrecord. When I use a custom address, I have no issues.
This leads me to believe that I have to use some other keyword to access the stored addresses but I have no clue what that would be.
h
Hi Tyler, i'm just curious to know if the shipping address subrecord that you mentioned above is the same as the Ship To select field ?