2016-07-28 53 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