Is there any way to modify a transaction's billing...
# suitescript
m
Is there any way to modify a transaction's billing/shipping addresses when working in Standard mode?
b
if you are doing this in a user event script, then fair chance you also need to manually update the shipaddress or billaddress text
m
It's done in a Restlet
I'll dig through those help docs, I haven't found anything in the SuiteScript API docs yet. I keep getting
Copy code
'SSS_INVALID_SUBLIST_OPERATION', details: 'You have attempted an invalid sublist or line item…ing to add or remove lines from a static sublist.',
when I do something like-
Copy code
var addressrec = rec.getSubrecord('shippingaddress');

      addressrec.setValue('country', address['country']);
      addressrec.setValue('zip', address['zipcode']);
...
eventually rec.save()
I think in those help docs it may be the
Be aware that not all subrecords have writable body fields.
but... I need to update the address record and I can't use dynamic mode
Perhaps a caveat is that the record in question is a Custom address subrecord on each transaction (not the address subrecord from the associated customer/vendor, we don't have Default Shipping set to true)
b
sounds weird, your body level subrecord isnt related to sublists
you probably want to find out which line is throwing that error
if its the save, then its probably another script
m
I can replicate in the console that error quite simply, I do not think it's another script-
Copy code
rec = record.load({
          type: 'salesorder',
          id: 24621,
        });
=> DeferredDynamicRecord {…}
var addressrec = rec.getSubrecord('shippingaddress')
=> undefined
addressrec.getValue('addr1')
=> '310, Cambridge Science Park'
addressrec.setValue('addr1', '315 Cambridge Science Park')
=> DeferredDynamicSubrecord {…}
addressrec.getValue('addr1')
=> '315 Cambridge Science Park'
rec.save()
=> N.js?NS_VER=2022.2&minver=15&buildver=30792:2438 Uncaught nlobjError {id: null, code: 'SSS_INVALID_SUBLIST_OPERATION', details: 'You have attempted an invalid sublist or line item…ing to add or remove lines from a static sublist.', stacktrace: 'stacktrace: function nlobjError(code, error, suppr…: undefined},[object Object],0,[object Object]}\n\n', suppressnotification: false, …}
load record, load subrecord, change value on subrecord, save record, see error. Should be replicable for you as well I assume?
Thank you for your time and insights btw, I appreciate it
b
the error is on save
which suggests another userevent script or workflow
m
Okay, so if you were to replicate the code you wouldn't see the same issue? I assumed it was just that the error message from modifying the sublist is only triggered when i save. This is done in chrome console so I also wasn't aware that would trigger any kind of workflow or script.
Wow, I didn't realize that at all. I was able to do these steps in a different environment and not encounter this issue. Thank you for the insight