PixelPaul
PixelPaul

Reputation: 1241

Netsuite webservices get order/invoice request, items type is blank

Does anyone know how to get the type of an item that is on an order or invoice via a getRequest?

When I get the list of items via the getRequest (webservices) from the order or invoice, the type fields in the items are empty.

So I can't then do a new getRequest to get the item because I don't know the item type. This then makes to many requests as I will need to do a search for the item ID first to find the item type to get the actual item.

EDITED

This is my getRequest:

$service = new APDIBLE\NetSuite\NetSuiteService($netsuite_config);
$request = new APDIBLE\NetSuite\Classes\GetRequest();
$request->baseRef = new APDIBLE\NetSuite\Classes\RecordRef();
$request->baseRef->internalId = $internalid;
$request->baseRef->type = 'salesOrder';
$getResponse = $service->get($request);

And that works fine, i get the salesOrder without error. It is just all the RecordRef fields including the items in the itemlist have an empty type field. I have noticed this is with every getRequest that i do for anything, they type field is always empty.

this is my XML Request if it helps:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:core_2015_1.platform.webservices.netsuite.com" xmlns:ns2="urn:messages_2015_1.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="ns">
<SOAP-ENV:Header>
    <ns3:applicationInfo xsi:type="ns2:ApplicationInfo">
        <ns2:applicationId>************************************</ns2:applicationId>
    </ns3:applicationInfo>
    <ns3:passport xsi:type="ns1:Passport">
        <ns1:email>**********</ns1:email>
        <ns1:password>***********</ns1:password>
        <ns1:account>***********</ns1:account>
        <ns1:role internalId="**********"/>
    </ns3:passport>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
    <ns2:get>
        <ns2:baseRef xsi:type="ns1:RecordRef" type="salesOrder" internalId="4153"/>
    </ns2:get>
</SOAP-ENV:Body>

and this is the returned item value of one of the list items:

 <tranSales:item internalId="2451" xmlns:platformCore="urn:core_2015_1.platform.webservices.netsuite.com">
                            <platformCore:name>test non-inventory item</platformCore:name>
                        </tranSales:item>

You can see the item ID and name is there but no type is returned. and this is the same for all RecordRef fields.

Upvotes: 2

Views: 1844

Answers (1)

iloveitaly
iloveitaly

Reputation: 2155

This is standard NetSuite behavior.

In nearly all cases where items are referenced the type is not defined alongside the record reference. There's not a way to change this behavior in the API. Searching for the item type is one way to pull the type so you can get the item from the NetSuite API.

You could also just attempt to get the item with a list of the most popular item types. This is often faster since a NetSuite get call to an invalid record reference is very quick to execute, often orders-of-magnitude faster than a search.

Here's an example implementation:

https://github.com/NetSweet/netsuite/blob/659d4634e8ab2ae26d8a860ecb5fc47a803da7c7/lib/netsuite/utilities.rb#L164

Upvotes: 0

Related Questions