2

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?

AVI
  • 5,516
  • 5
  • 29
  • 38
Russ Petersen
  • 765
  • 1
  • 9
  • 29

1 Answers1

4

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);
Shea Brennan
  • 1,132
  • 7
  • 16
  • How do I indicate the type of transaction when I set the field to the record's id field? – Russ Petersen Feb 19 '16 at 01:15
  • 1
    You don't need to. Transaction internal id's are unique regardless of transaction type. They're all 'unique' elements of the `List` -> `Transaction` – Shea Brennan Feb 19 '16 at 01:31