0
votes

I have a strange situation. I am validating shipping address of an opened in Edit mode Sales Order. So with my Client Script attached to the Sales Order Record, I collect data from object:

var address = currentRecord.get().getSubrecord("shippingaddress")

Which is an instance of a read-only subrecord address, so I can read it like

var addr1 = address.getValue({fieldId: 'addr1'});
var city = address.getValue({fieldId: 'city'});
// ... and so on

That is ok, I then send this to the my validation server get response and all is ok.

My validation server returns the corrected address, so I want it to apply to current Sales Order shipping address. As the subrecord shippingaddress is read-only, I want to select " - Custom - " address, which opens a pop-up with a Custom Address Form, I attach Form Script on Custom Address Form to populate this data, taken from the main window (I could save correct address it on window or localStorage, even though NetSuite docs do not recommend it, but still, just to make it work).

And here is the problem. Right after I attach a Client Script to the Custom Address Form, I no longer can get a shippingaddress in the main window. When I run:

var address = currentRecord.get().getSubrecord("shippingaddress")

I get null, and I don't know why.

Do you have any idea what could be the reason, or maybe any other ideas to achieve this task? Thank you

2

2 Answers

1
votes

NetSuite currently does not allow setting custom address from SuiteScript 2.0 in edit mode or even through client-script. So what you can do is update shipping address in user-event afterSubmit or through workflow.

0
votes

I think you should use

var shipaddress = nlapiViewSubrecord('shippingaddress')
var shipcountry = shipaddress.getFieldText('country');
var shipstate = shipaddress.getFieldText('dropdownstate');