I am trying to import sales order from magento to ...
# suitescript
a
I am trying to import sales order from magento to netsuite .. Problem is that i am successfully able to pull out sales order but the shipping address [Ship To] address is not imported Instead the default address saved for the customer is selected as the ship to address for the sales order. var salesOrder = record.create({ type: record.Type.SALES_ORDER, isDynamic: true, }); var subrec = salesOrder.getSubrecord({ fieldId: 'shippingaddress' }); addr1 = "Street, "+data["shipping_address"]["street"]["#text"]; subrec.setValue({ fieldId: 'addr1', value: addr1 }); subrec.setValue({ fieldId: 'city', value: data["shipping_address"]["city"]["#text"] }); subrec.setValue({ fieldId: 'state', value: data["shipping_address"]["region"]["#text"] }); subrec.setValue({ fieldId: 'zip', value: data["shipping_address"]["postcode"]["#text"] }); subrec.setValue({ fieldId: 'country', value: data["shipping_address"]["country_id"]["#text"] }); subrec.setValue({ fieldId: 'addressee', value: data["customer_firstname"]["#text"]+' '+data["customer_lastname"]["#text"] }); subrec.setValue({ fieldId: 'attention', value: data["customer_firstname"]["#text"] });
b
for dynamic mode the order fields are set matters
do you set the address first or the customer
a
customer
Shall i set customer after the shipping address?
b
customer first
the general idea is to set the fields in the same order you would in the ui
a
i tried that as well .. but issue was still there ..
For the customer that exists in Netsuite ., Magento address is ignored and the already saved address is put in the shipping address ship to field
Am i missing something in the code
b
you can try setting country first
a
Tried that .. same issue .. shipaddresslist ..
shipaddresslist Select the appropriate shipping address for this transaction. * Select New to enter a new shipping address to be used for this transaction and saved with the associated entity record. * Select Custom to enter a new shipping address to be used for this transaction only (and not saved with the associated entity record). * Click the Edit icon to edit an existing shipping address.
Found this on the record browser .. can my issue resolve by using this key "shipaddresslist" . Do you knwo how to use this
b
its not supposed to
is the address subrecord incorrect
or is only the shipaddress text box wrong
a
shipaddress only
Only the Ship Address is wrong which comes under Ship To label
b
dont use dynamic mode
or overwrite the shipaddress field with the addrtext from the subrecord
a
it still doesnt work.. showing default address
b
if you are using dynamic mode, share how (and where) you overwrote the shipaddress
if you arent using dynamic mode, share your new code
a
Using dynamic mode: var salesOrder = record.create({ type: record.Type.SALES_ORDER, isDynamic: true, }); var subrec = salesOrder.removeSubrecord({ fieldId: 'shippingaddress' }); var subrec = salesOrder.getSubrecord({ fieldId: 'shippingaddress' }); addr1 = "Street, "+data["shipping_address"]["street"]["#text"]; subrec.setValue({ fieldId: 'addr1', value: addr1 }); subrec.setValue({ fieldId: 'city', value: data["shipping_address"]["city"]["#text"] }); subrec.setValue({ fieldId: 'state', value: data["shipping_address"]["region"]["#text"] }); subrec.setValue({ fieldId: 'zip', value: data["shipping_address"]["postcode"]["#text"] }); subrec.setValue({ fieldId: 'country', value: data["shipping_address"]["country_id"]["#text"] }); subrec.setValue({ fieldId: 'addressee', value: data["customer_firstname"]["#text"]+' '+data["customer_lastname"]["#text"] }); subrec.setValue({ fieldId: 'attention', value: data["customer_firstname"]["#text"] });
But still shows the default shipping address of the customer in order shipping address.
salesOrder.setValue({ fieldId: 'shipaddresslist', value: null }); Seems like this line did the trick, will test more
g
I set shipaddresslist to null, works for me
salesOrder.setValue({                         fieldId: 'shipaddresslist',                         value: null                     });                                          var shippingAddressRecord = salesOrder.getSubrecord('shippingaddress');                     var shippingAddressDetails = this.getAddressDetails(order.shipping_address, shipPhone);                     util.each(shippingAddressDetails, function(v, k) {                         shippingAddressRecord.setValue({                             fieldId: k,                             value: v                         });                         return true;                     })
in dynamic mode of cause, and it creates custom address record, tested and bullet approve