I'm trying to create a sales order script that pulls the XML from ebay and then creates a sales order according to the information.
Its working when I use the following code to save the address from the XML to addressbook on customer record and then use it as the shipping address using the below code
var xmlobj = nlapiStringToXML(xmlstring);
var customerInternalID = findCustomerByEbayID(nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//BuyerUserID'));
if (!customerInternalID){
var customer = nlapiCreateRecord('customer');
customer.setFieldValue('subsidiary', SUBSIDIARY);
customer.setFieldValue('isperson', 'T');
var emailAddr = nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//Buyer/Email');
if (emailAddr.indexOf("@") === -1 ){
emailAddr = nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//Buyer/StaticAlias');
}
if (emailAddr.indexOf("@") === -1 ){
emailAddr = null;
}
customer.setFieldValue('email', emailAddr);
customer.setFieldValue('custentity_ebay_user_id', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//BuyerUserID'));
customer.setFieldValue('firstname', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//UserFirstName'));
customer.setFieldValue('lastname', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//UserLastName'));
customer.setFieldValue('phone', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Phone').substring(0, 12));
customer.setLineItemValue('addressbook', 'addressee', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Name'));
customer.setLineItemValue('addressbook', 'addr1', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Street1'));
customer.setLineItemValue('addressbook', 'addr2', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Street2'));
customer.setLineItemValue('addressbook', 'addr3', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Street3'));
customer.setLineItemValue('addressbook', 'city', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/CityName'));
customer.setLineItemValue('addressbook', 'state', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/StateOrProvince'));
customer.setLineItemValue('addressbook', 'zip', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/PostalCode'));
customer.setLineItemValue('addressbook', 'country', 1, nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Country'));
customer.setFieldValue('custentity11', 'T');
customerInternalID = nlapiSubmitRecord(customer, true, true);
nlapiLogExecution('DEBUG', 'SUBMIT', 'Customer submitted with internal ID' + customerInternalID);
}
var customerRec = nlapiLoadRecord('customer', customerInternalID);
var defaultAddress = customerRec.getLineItemValues('addressbook', 'id', 1);
but when I try to use the address from XML directly as shipping address using the below code, I'm ending up having no address on the sales order
var defaultAddress = nlapiSelectValues(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress');