TKarr
TKarr

Reputation: 13

How do I call NetSuite SuiteTalk inventoryitem add using list name for StringCustomFieldRef value instead of internalID?

When adding a new inventoryitem through the API we have a few list based custom fields we need to fill in. I want to be able to use the string value for the field but when I try to the call errors out.

We have a custom list with two values: InternalId 1 is "LTL" InternalId 2 is "FedEx"

I have tried sending the value across as a StringCustomFieldRef and when setting the value to the string value of the "LTL" we get an invalid ref error. When setting the value to the internalId of 1 it works.

I also tried using a SelectCustomFieldRef and when setting the value->name to the string value of "LTL" it errors like we did not pass the value at all. When we set value->internalId to 1 it works.

Is it possible to just pass in the string value?

Does not work:

                $customField1 = new StringCustomFieldRef();
                $customField1 ->value = "LTL";
                $customField1 ->scriptId = 'custitem_zu_zu_fulfill_pref';

Works:

                $customField1 = new StringCustomFieldRef();
                $customField1 ->value = "1";
                $customField1 ->scriptId = 'custitem_zu_zu_fulfill_pref';

This is the error response:

<platformCore:statusDetail type="ERROR">
    <platformCore:code>INVALID_KEY_OR_REF</platformCore:code>
    <platformCore:message>Invalid custitem_zu_zu_fulfill_pref reference key LTL.</platformCore:message>
</platformCore:statusDetail>

Upvotes: 1

Views: 294

Answers (1)

Will Charbonneau
Will Charbonneau

Reputation: 101

No, unfortunately you cannot set a field with the Name value--you will have to use the internalId. If your custom field is list-based, then you should be using SelectCustomFieldRef or MultiSelectCustomFieldRef.

If you wish to use the Name value, you can perform a CustomListSearchBasic to get the Name and internalId of each item, and match that to your chosen Name.

Upvotes: 1

Related Questions