Issue
In a vendor return record, a client script is deployed. In the pageInit of the script, the code intended to set the inventory details for the item lines. But when the pageInit was triggered, an error occurred saying selectNewLine is not a function when the script was trying to set the inventory detail. Also, an alert was shown as below. The item was a lot number item.

Root Cause
In the client script pageInIt and the user event beforeLoad, the inventory detail which is a subrecord cannot be set due to the following reason. However, subrecords are read-only when their parent records are retrieved in either of the following ways:
- Through the context object provided to a client script, or through currentRecord.get().
- Through the context object provided to a beforeLoad user event script.
Client Scripts Deployed on Parent Records (with Limitations)
A client script may not create subrecords on the current record and is limited to read-only access of existing subrecords on the current record. The client script may remove the subrecord from the current record. You cannot deploy a client script directly on a subrecord type. However, you can customize an address form, as described in the following section. You cannot deploy a client script directly to a subrecord type.