Reputation: 765
I've created a custom Transaction Body Field named "Created From" of type List/Record - Transaction
That I want to be have like the native NetSuite Created From fields. I have added this custom field to the Customer Refund form and when entering (or editing) the refund if I give a value of "Sales Order #1234
" it saves correctly and becomes a link to the sales order. But when I try to set it using code
customerRefund.setFieldValue("custbody_ifx_created_from", "Sales Order #" + salesOrderId);
id = nlapiSubmitRecord(customerRefund);
This error is generated
Error: INVALID_KEY_OR_REF Invalid custbody_ifx_created_from reference key Sales Order #81388396.
How can I create a valid key or reference to another record?
Upvotes: 2
Views: 2310
Reputation: 1132
The type of your custom field is list/record
->transaction
. You need to populate it with the internal id of a transaction record. That will allow you to submit the record. When viewed through the UI, it will display the 'Sales Order# XXX' text as expected.
customerRefund.setFieldValue("custbody_ifx_created_from", salesOrderInternalId);
id = nlapiSubmitRecord(customerRefund);
Upvotes: 4