FYI on the RP, seems we aren't allowed to add new ...
# suitescript
f
FYI on the RP, seems we aren't allowed to add new properties to the record object anymore: var rec = context.newRecord; //this is throwing an error rec.myFunction = function(){ log.debug("hi") } rec.myFunction(); //this works rec.proto.myFunction = function(){ log.debug("hi") } rec.myFunction();
👎 1
j
Yeah I was previously doing something like
rec.id = rec.save();
for new records since
rec.save()
does not update the id property of the record object. Since 2018.1 that throws a
READ_ONLY_PROPERTY
error
s
that particular case may be special @jkabot - that 'id' field is something that is defined in SS2. I am against the notion of adding to ANY netsuite controlled objects - that way be dragons.
On the other hand, no problem if one wants to wrap or otherwise contain a NS object, I just don't dare to modify it directly. I especially wouldn't modify proto . Heck
__proto__
isn't even a real thing.
j
Yeah I thought the "fix" for my case was fair game since it was "documented" to be "read-only". I was just annoyed that I'd have to wrap an object around the record if I wanted to pass around the saved record as well as its id
s
FWIW, I think NFT does exactly this - since it wraps NS records anyway, it tries to keep the
id
field in sync (without modifying the underlying NetSuite.Record)
👍 1