https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
c

Craig

03/31/2022, 9:05 PM
setValue() on fields in the shippingaddress subrecord (on an SO) should save when the SO saves right? I'm setting the fields in beforeSubmit but the saved transaction isn't showing the fields I've set.
b

battk

03/31/2022, 9:06 PM
is the
shipaddress
field not being set correctly
or are the actual fields on the subrecord not being set
c

Craig

03/31/2022, 9:07 PM
The latter
in regards to the former, I'm not interacting with the shipaddress field.
b

battk

03/31/2022, 9:08 PM
are you using the
shipaddress
field in the ui to tell if the subrecord has changed
or are you actually examining the actual address subrecord
c

Craig

03/31/2022, 9:08 PM
Yes, that's the field I'm using to visually confirm
b

battk

03/31/2022, 9:09 PM
edit the sales order in the ui and edit the address to see the actual address subrecord to confirm
c

Craig

03/31/2022, 9:16 PM
After some poking around I can see the addresses I've been setting have all been saved but the shipaddress field is not set to the saved address
and the fields are being correctly set and saved on the subrecord
b

battk

03/31/2022, 9:18 PM
extra common for the address fields to not source correctly
the sure fix is to set the
shipaddress
yourself
the exotic fix is to use Record.removeSubrecord first
c

Craig

03/31/2022, 10:04 PM
@battk it looks like this one line of code fixed the issue:
Copy code
soRecord.setValue({fieldId: 'shipaddresslist', value: ''});
the shipaddress now shows the values I set in the subrecord.
I got that from a SuiteAnswer - I don't know why that works, I think it forces the address to be added as 'custom' instead of 'new'.
typical NS, very obscure fix/workaround that you only find out by luck.