Hi... I have this record added by the Electronic I...
# suitescript
m
Hi... I have this record added by the Electronic Invoice bundle It is included as a sublist subrecord under customers sublist ID is
recmachcustrecord_psg_ei_email_recipient_cust
I am trying to add a row to it using suitescript but I keep getting this error
Copy code
{"type":"error.SuiteScriptError","name":"FIELD_1_IS_NOT_A_SUBRECORD_FIELD","message":"Field custrecord_psg_ei_email_recipient_cust is not a subrecord field.","id":.......
This is my code
Copy code
let recipient = context.newRecord.getSublistSubrecord({
  sublistId: "recmachcustrecord_psg_ei_email_recipient_cust",
  fieldId: "custrecord_psg_ei_email_recipient_cont",
  line: 0,
});
I tried other IDs but nothing worked Any easy way to know what is the ID of the field that holds the subrecord? Do I understand this correctly?
b
there is no such thing as a custom subrecord
custom records cannot have a subrecord
m
The parent is the Customer record.
Not a custom record.
From the docs:
Copy code
Create the new subrecord with the Record.getCurrentSublistSubrecord(options) method. This method takes two arguments:

A sublistId, which identifies the sublist.

A fieldId, which identifies the field on the sublist that contains the subrecord. In the Records Browser, the field that holds the subrecord is always identified as a field of type summary.
Then there is a special field that holds the subrecord... I can't identify it.
b
your screenshot is of a custom record
that is not a subrecord
m
Yeah
b
you will never access it as a subrecord
m
Isn't the subrecord just a child record that could be custom or standard?
How can I access it?
b
thats not what a subrecord is
m
Hmm, I will read more about it then.
Thanks
b
SuiteScript 2.x Scripting Subrecords is the usual starting place to learn about subrecords
Custom Child Record Sublist Creation with SuiteScript is where you learn how to work with parent/child relationships
m
Thanks 🙏