Record cannot be saved. Transaction nexus is not valid for transaction subsidiary.

Scenario

While adding the shipping address via script user encounters error: “Record cannot be saved. Transaction nexus <nexus> is not valid for transaction subsidiary <subsidiary>.”

Solution

The field ‘entitynexus’ might be changed after setting the shipping address, causing the error. To resolve this, get its value prior to setting the shipping address and set it back immediately after.

let entitynexus = order.getFieldValue("entitynexus");

/* shipping address*/

order.setFieldValue('shipaddressee', dataIn.shipaddr.addressee);
order.setFieldValue('shipaddr1', dataIn.shipaddr.addr1);
order.setFieldValue('shipaddr2', dataIn.shipaddr.addr2);
order.setFieldValue('shipcity', dataIn.shipaddr.city);
order.setFieldValue('shipcountry', dataIn.shipaddr.country);

order.setFieldValue('shipphone', dataIn.shipaddr.phone);
order.setFieldValue('shipstate', dataIn.shipaddr.state);
order.setFieldValue('shipzip', dataIn.shipaddr.zip);

order.setFieldValue("entitynexus", entitynexus);

Leave a comment

Your email address will not be published. Required fields are marked *