2016-07-28 41 views
1

我有這個現有的代碼片段,用於搜索由其RecordType指定的記錄列表(例如InventoryItem,SalesOrder)。在Netsuite中搜索裝運項目API

$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; 
} 

但是,似乎在RecordType中沒有Shipping Item,儘管我可以傳遞一個內部ID。我的目標是讓我的計算中使用的貨運細節用於創建銷售訂單(需要在提交之前顯示)。

獲取運輸項目記錄是否有不同的方法?怎麼樣?

回答

0

我現在可以通過RESTlets成功檢索運輸項目。我首先在File Cabinet中將其作爲新文件上傳,然後將其添加爲新腳本。創建新腳本時,NetSuite不允許直接上傳腳本文件。

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

然後使用guzzle http庫來調用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()); 
2

Shippinget記錄尚不支持在Suitetalk中。作爲替代解決方案,您可以創建RESTlet來獲取Shipping Item。

+0

好的,謝謝,我會看看關於如何做到這一點的RESTlet的文檔。基於我所知道的,我將創建一個定製腳本來獲取運輸項目,然後從我的代碼庫調用restlet服務,對嗎?如果我設法實現它,我會在這裏發佈我的實現。 – oLraX