Suitescript - 使用getSelectOptions

时间:2016-08-01 14:16:25

标签: php netsuite guzzle suitescript

我正在尝试检索销售订单表单的送货方式的可用选项,但我在使用getSelectOptions时遇到意外错误。

function get_select_options(datain)
{
    var rec = nlapiCreateRecord(datain.recordType);    
    var field = rec.getField(datain.field);
    var options = field.getSelectOptions();

    return options;
}

这是我调用脚本的代码。

$url = "https://rest.sandbox.netsuite.com/app/site/hosting/restlet.nl";
$client = new 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',
        'deploy' => '1',
        'recordType' => 'salesorder',
        'field' => 'shipmethod'
    ]
]);

return json_decode($response->getBody());

我的记录类型和字段似乎正如我在文档中读到的那样。我还遵循了一些使用getSelectOptions的示例代码,但由于一些意外/未知错误,我无法继续前进。我还试图只返回记录(rec),以确保我的PHP代码正常工作。

GuzzleHttp\Exception\ServerException with message 
'Server error: `GET https://rest.sandbox.netsuite.com/app/site/hosting/restlet.nl?script=343&deploy=1&recordType=salesorder&field=shipmethod` 
resulted in a `500 Internal Server Error` response: 
{"error" : {"code" : "UNEXPECTED_ERROR", "message" : "An unexpected error has occurred. Error ID: irc3j6d915k2asvrqbfhb" (truncated...) '

0 个答案:

没有答案