Roberto Carlos
10/14/2022, 2:33 PM/**
* Adds an item to the sales order record being created.
* @param salesOrderObj Object referring the sales order record the item belongs to.
* @param itemId The ID of the item to be added.
* @param line The position of the item within the sales order items sublist.
* @param expectedShipDate The shipping date of the order the item belongs to.
*/
public addItem(salesOrderObj, itemId, line, ItemInfo, expectedShipDate: Date, subsidiary, locationId) {
try {
let countryCode = this.nsHelper.searchCountry(this.customer.customerInfo.Address.Country);
// Inserting a new item (line) to the items sublist of the order
salesOrderObj.insertLine({
sublistId: 'item',
line: line
});
// Setting the item through its internal ID.
salesOrderObj.setSublistValue({
sublistId: 'item',
fieldId: 'item',
value: itemId,
line: line
});
// Defining the quantity of items the customer bought.
salesOrderObj.setSublistValue({
sublistId: 'item',
fieldId: 'quantity',
value: ItemInfo.Quantity,
line: line
});
// Defining the expected ship date of the item the customer bought.
salesOrderObj.setSublistValue({
sublistId: 'item',
fieldId: 'expectedshipdate',
value: expectedShipDate,
line: line
});
// Defining the location of the item the customer bought.
salesOrderObj.setSublistValue({
sublistId: 'item',
fieldId: 'inventorylocation',
value: locationId,
line: line
});
// Defining the total amount to be paid by the US customers.
salesOrderObj.setSublistValue({
sublistId: 'item',
fieldId: 'amount',
value: ItemInfo.Cost,
line: line
});
}
catch (e) {
this.log.error({
title: `addItem error: ${e.name}`,
details: "An error occurred while adding an item to the sales order: " + e.message
});
}
}
Mark Oriend
10/14/2022, 2:36 PMRoberto Carlos
10/14/2022, 3:09 PMbattk
10/14/2022, 8:38 PMbattk
10/14/2022, 8:40 PM