RE: Netsuite get records using Sales Order Internal ID
I am using the PHP Toolkit to retrieve Netsuite Sales Order details using pre-built search techniques. I have the internal ID of a sales order, and I want to retrieve records linked to that sales order, such as invoices, cash sales, RMAs, etc. If you have any insights on this or sample code, please update or share it.
. Using Pre-built Search Techniques:
The PHP Toolkit offers pre-built search techniques for various record types. You can leverage them to efficiently retrieve linked records:
PHP
// Use the Record::get() method for single record retrieval
$invoice = Record::get(RecordType::INVOICE, $invoiceId);
// Use the Search::create() method for multi-record searches
$cashSalesSearch = Search::create(RecordType::CASH_SALE);
$cashSalesSearch->addColumn('internalid'); // Select only internal IDs
$cashSalesSearch->addFilter('createdfrom.internalid', $salesOrderId);
$cashSales = $cashSalesSearch->run();
// Use custom filters and columns for RMAs
$rmaSearch = Search::create(RecordType::RETURN_AUTHORIZATION);
$rmaSearch->addColumn('tranid', 'tran_id'); // Rename returned column
$rmaSearch->addFilter('salesorder.internalid', $salesOrderId);
$rmas = $rmaSearch->run();