how do i save a value on a custom body field in a...
# suitescript
g
how do i save a value on a custom body field in a saveRecord script? when i do saveRecodrd it says that the record has changed, when I leave it - it doesnt save
b
what have you tried
s
Can you set field values in a saveRecord entry point? I've never tried. It's more for validation than setting a value.
e
There's nothing stopping you from doing so
I'm going to go out on a limb and guess that you have loaded the record that's in context, then modified the version in memory and saved it, then when the
saveRecord
entry point completes and attempts to save the record to the database, it sees that it has been changed (by your code) and throws that error.
g
@erictgrubaugh Right, that is what happened, how to i allow a save on that record, and then continue on as reg. (reload the record in context)?
s
Why do you want to allow the save and then reload it? That is not typical behavior you would want in a client script.
e
I'm guessing the goal is to set some other field(s) on the client side as the record is saved. In which case, instead of loading the record, you should be setting the body field via the
currentRecord
instance that gets passed into your
saveRecord
entry point
Copy code
function saveRecord(context) {
  context.currentRecord.setValue({fieldId: "custbody_blah", value: "Bob Loblaw"});
  return true;
}
g
@erictgrubaugh Thanks! But how would i do the shippnig address, a subrecorod?
Are subrecords really only read only in client script? how would i edit and have a popup in the same script without getting too complicated?