Netsuite Error INVALID_KEY_OR_REF

孤者浪人 提交于 2019-12-12 05:26:27

问题


Getting this error Invalid custrecord_lt_partner reference key 225399. While trying to insert into

The first two fields are lists/records & the third field is free form text.

Netsuite with Admin rights

Here is the code

global $nsClient;

$recordTypeRef = array("internalId" => 91);

$partnerName = "225399";
$companyName = "20562";
$labAcctNum  = "7182794";

$partnerNameFields = new nsComplexObject('SelectCustomFieldRef');

$partnerNameFields->setFields(
    array(
        'value'         => new nsListOrRecordRef(array('internalId' => $partnerName)),
        'internalId'    => 'custrecord_lt_partner' 
    )
);

$companyNameFields = new nsComplexObject('SelectCustomFieldRef');

$companyNameFields->setFields(
    array(
        'value'         => new nsListOrRecordRef(array('internalId' => $companyName)),
        'internalId'    => 'custrecord_lt_company' 
    )
);


$labAcctNumFields = new nsComplexObject('StringCustomFieldRef');

$labAcctNumFields->setFields(
    array(
        'internalId' => 'custrecord_lt_user_lab_acct_number',
        'value'      => $labAcctNum, 
    )
);


$customRecordFields = array(
    "recType"           => $recordTypeRef,
    "customFieldList"   => array($partnerNameFields, $companyNameFields, $labAcctNumFields),
);


$customRecord = new nsComplexObject('CustomRecord');

$customRecord->setFields($customRecordFields);

//echo "<pre>"; print_r($customRecord); echo "</pre>"; exit;


$addResponse = $nsClient->add($customRecord);

if($addResponse->isSuccess) {
    echo "<pre>"; print_r("Success"); echo "</pre>"; exit;
}
else {
    echo "<pre>"; print_r($addResponse->statusDetail[0]->message); echo "</pre>"; exit;
}

回答1:


I get this error when the internalID specified does not exist. So I assume that the value of $partnerId is "225399". Did you double check in Netsuite that an entry with that ID exists? (The URL or the System Tab usually tells you more. Alongside SelectFields there's usually also a Javascript array where you can find the IDs).




回答2:


Is $partnerName the entityId field from the partner record, or the internalId field?

You need to supply either an internalId or externalId. Your use of the word "name" within your variable makes me think you are not using internal or external Id.



来源:https://stackoverflow.com/questions/13256994/netsuite-error-invalid-key-or-ref

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!