Hello <#C298P0BCK|>, Does anybody know what is the...
# general
r
Hello #C298P0BCK, Does anybody know what is the field ID to set the item location for a line item into a sales order in Netsuite using SuiteScript 2.1? I'm using the code below -with the field 'inventorylocation'- to add an item to a sales order but it doesn't take the ID I'm passing through the parameters. The salesOrderObj is NOT charged dynamically. Everything is working except setting the location.
Copy code
/**
 * 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
        });
    }
}
m
Please use location. not inventorylocation
r
Thanks @Mark Oriend, I tried with location but it didn't work yet. I saw it is 'inventorylocation' to set the location for the line item in the documentation, specifically at https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2022_1/script/record/salesorder.html, in the Sublists section. I guess it would be another problem but I don't know if this location depends on other fields I'm defining for the sales order.
b
inventory location and location are different fields with different purposes
if you dont know how to tell the difference, create the order you want in the ui, then load it in script to inspect what it looks like to copy it