0

I'm working with Customer records in a User Event beforeLoad script. Since record.setValue doesn't work in beforeLoad, I'm using record.submitFields to submit 3 field values. This works most of the time, however rarely there is a USER_ERROR:

{"type": "error.SuiteScriptError", "name":"USER_ERROR", "message": "This entity was marked as a master in a duplicate resolution operation.<br><br>This operation is in progress, and the entity is temporarily unavailable for editing."}

In the error it points to the line where my record.submitFields is located. From my research into the issue, I think there is somehow a separate process also trying to submitFields and creating a second record to be saved. But I've been through the scripted records and can't seem to find any scripts that could be causing that. Does anyone have thoughts on what could be happening and how it's typically fixed?

T_lastname
  • 122
  • 9

1 Answers1

0

Since record.setValue doesn't work in beforeLoad

This is not really accurate. You can't (or shouldn't) use the N/record module to load the record that a beforeLoad event is firing for, because that means you're attempting to load it twice at one time. You can work with the Record object passed in the scriptContext to the beforeLoad event:

function beforeLoad (scriptContext) {
    var newRecord = scriptContext.newRecord;
    newRecord.setValue(...) //now you can set values
}

These values will now be present in the loaded record.

Krypton
  • 4,394
  • 2
  • 9
  • 13
  • This actually doesn't work. It's the whole reason I've gone down this rabbit hole in the first place. Here's a different post that discusses the issue with beforeLoad, and directed me toward record.submitFields https://stackoverflow.com/questions/56138978/netsuite-script-beforeload-record-not-being-modified – T_lastname Nov 01 '22 at 04:22
  • @T_lastname please accept my apologies. When I saw the question I *"knew"* that it works ok because I had used it recently. However, when I went back now and rechecked I noticed that I'm using it on COPY, which of course would be acting on a new record, not existing. Another suggestion would be to move your logic to the `pageInit` event in a client script. – Krypton Nov 01 '22 at 14:49