NetSuite PHP Toolkit: Get Item By Internal ID

March 20th, 2023

A few simple lines to pull an item by its item id.

The NetSuite PHP Toolkit is surprisingly fully featured but not very well documented.

This will be the first of several short snippets I post as I work with it.

This snippet fetches an item record from NetSuite given its internal ID.

require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$request = new GetRequest()
$request->baseRef = new RecordRef();
$request->baseRef->internalId = "INTERNAL_ID_HERE";
$request->baseRef->type = "inventoryItem";
$getResponse = $service->get($request);
if (!$getResponse->readResponse->status->isSuccess) {
    echo "Failed to get item";
} else {
    $item = $getResponse->readResponse->record;
    echo "Item Details:";
    echo "<pre>";
    echo "</pre>";

Make sure your NSConfig.php file is set up before doing this and you should see the results of your query returned.

The returned item record from NetSuite.

The returned item record from NetSuite.


Leave a Reply

Your email address will not be published. Required fields are marked *