oLraX
oLraX

Reputation: 217

Search Shipping Item in Netsuite API

I have this existing code snippet that searches list of records specified by its RecordType (e.g. InventoryItem, SalesOrder).

 $request = new GetRequest();
 $request->baseRef = new RecordRef();
 $request->baseRef->type = $type;  //Record Type
 $request->baseRef->internalId = $internalId; //Internal ID of record

 $getResponse = $service->get($request);
 if ( ! $getResponse->readResponse->status->isSuccess) {
     return 'ERROR';
 } else {
     return $getResponse->readResponse->record;
 }

However, it seems that there's no Shipping Item in the list in RecordType although I can pass an internal ID. My goal here was to get the shipping item details to be used in my computation for creating a sales order (needs to be displayed before submitting).

Will there be a different approach in getting the shipping item record? How?

Upvotes: 1

Views: 1829

Answers (2)

oLraX
oLraX

Reputation: 217

I can now successfully retrieve Shipping items via RESTlets. I uploaded this first as new in the File Cabinet, then added it as a new script. NetSuite does not allow direct upload of script file when creating a new script.

// get_record.js
function get_record(datain)
{
    var record = nlapiLoadRecord(datain.recordType, datain.id);
    return record;
}

Then used guzzle http library to call the RESTlet.

    $url = "https://rest.sandbox.netsuite.com/app/site/hosting/restlet.nl";
    $client = new GuzzleHttp\Client();

    $authorization = [
        'NLAuth nlauth_account='.getenv('NETSUITE_ACCOUNT'),
        'nlauth_email='.getenv('NETSUITE_EMAIL'),
        'nlauth_signature='.getenv('NETSUITE_PASSWORD'),
        'nlauth_role='.getenv('NETSUITE_ROLE')
    ];

    $response = $client->request('GET', $url, [
        'headers' => [
            'Authorization' => implode(',', $authorization),
            'Content-Type' => 'application/json'
        ],
        'query' => [
            'script' => '343', //script id
            'deploy' => '1',
            'recordType' => 'ShipItem', 
            'id' => '5905' // example of internal id of desired shipping item
        ]
    ]);

    return json_decode($response->getBody());

Upvotes: 0

vVinceth
vVinceth

Reputation: 915

Shipping Item record is not yet supported in Suitetalk. As an alternate solution you can create a RESTlet instead to get the Shipping Item.

Upvotes: 2

Related Questions