How to get Quantity On Hand and Quantity On Hand (...
# ask-stanley-ai
v
How to get Quantity On Hand and Quantity On Hand (Base Unit) from item using php tollkit
c
AI generated answer (using internal Slack threads):
To get the Quantity On Hand and Quantity On Hand (Base Unit) from an item using the PHP toolkit, you would need to use the
getItemAvailability
operation. This operation returns the quantity available for a list of items at specified locations. Here is a sample code snippet:
Copy code
php
require_once 'NetSuiteService.php';

$service = new NetSuiteService();

$itemAvailabilityFilter = new ItemAvailabilityFilter();
$itemAvailabilityFilter->item = array();
$itemAvailabilityFilter->item[0] = new RecordRef();
$itemAvailabilityFilter->item[0]->internalId = '104'; // replace with your item internalId
$itemAvailabilityFilter->item[0]->type = 'inventoryItem';

$request = new GetItemAvailabilityRequest();
$request->itemAvailabilityFilter = $itemAvailabilityFilter;

$getItemAvailabilityResponse = $service->getItemAvailability($request);

if (!$getItemAvailabilityResponse->getItemAvailabilityResult->status->isSuccess) {
    echo "GET ITEM AVAILABILITY ERROR";
} else {
    echo "GET ITEM AVAILABILITY SUCCESS, RESULTS:\n";
    foreach ($getItemAvailabilityResponse->getItemAvailabilityResult->itemAvailabilityList->itemAvailability as $itemAvailability) {
        echo "Item: ".$itemAvailability->item->name."\n";
        echo "Quantity Available: ".$itemAvailability->quantityOnHand."\n";
    }
}
This code will return the quantity on hand for the specified item. You can adjust the
internalId
to match the item you are interested in. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815490723
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.81475836
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811248899
Please provide your feedback on this answer.