Coldstar
Coldstar

Reputation: 1341

NetSuite: Getting the shipcity from a salesorder in SuiteScript 2.0

If I load a sales order using the code below, how do I get the shipcity. Note that if you dump the object (salesOrder) you will see that there is NO shipcity. Whats strange is that shipzip, shipstate and shipcountry have their own fields but shipcity does not. I also tried billcity but to no avail. This seems like a big disconnect. The shipcity should say Fort Wayne like it does in the UI but the 2.0 API returns nothing

// load up a sales order from a Fort Worth customer
var salesOrder = record.load({
   type: record.Type.SALES_ORDER,
   id: salesOrderId,
   isDynamic: true
});

// these work fine
salesOrder.getValue("shipcountry") = "US"
salesOrder.getValue("shipstate") = "IN"
salesOrder.getValue("shipzip") = "46804"

// none of the following work when it should say "Fort Wayne"
salesOrder.getValue("shipcity") = Null
salesOrder.getValue({ fieldId: "shipcity" }) = Null
salesOrder.getText("shipcity") = Null

Upvotes: 3

Views: 1550

Answers (1)

Leibnitz Jacquard
Leibnitz Jacquard

Reputation: 469

I just confirmed it. With SS1.0 we can have value for 'shipcity' but not with SS2.0 for some reason. So let's get it with different approach using 'N/search' module. You may either create a search or do lookup. But I would suggest you to use lookup since you are just getting value at the header. Please try sample code below:

By the way, please hard code the value for type and don't use 'search.Type.SALES_ORDER'. For some reasons, it will error out.

require(
[
    'N/search'
], function(search)
{
var objFieldLookUp = search.lookupFields(
    {
        type : 'salesorder',
        id : 34826,
        columns :
            [
                    'shipcountry', 'shipstate', 'shipzip', 'shipcity'
            ]
    });

var stCountry = objFieldLookUp["shipcountry"];
var stState = objFieldLookUp["shipstate"];
var stZip = objFieldLookUp["shipzip"];
var stCity = objFieldLookUp["shipcity"];
});

Upvotes: 2

Related Questions