Anyone ever get this error? Trying to call setValu...
# suitescript
c
Anyone ever get this error? Trying to call setValue on currentrecord:
s
you probably need
r=> r.id ==
c
Sorry that line below is unrelated
s
then you'll need to share the code that is causing the error 🙂
e.g.
_validateField
implementation
it's likely the error description is accurate.
c
So basically, on the sales order if I just run the following it logs that error and then completely refreshes the page.
require(["N/currentRecord"])
rec = require("N/currentRecord")
cr = rec.get()
cr.setValue("entity",6433)
message has been deleted
s
you're doing this from the console? For one thing, the signature for
setValue
is not (string, number) even if that works sometimes it's not documented as such?
the error above is different than your original
c
So I’m actually running this as part of javascript embedded in an HTML field added during user event script
the N/query module works just fine but I can’t set fields via currentRecord
The full javascript being embedded on the page is:
Copy code
<script>
    require(["N/query","N/currentRecord"], (query, currentRecord)=> {
        rec = currentRecord.get()
        rec.setValue({fieldId: "entity", value: 20042})
    }
</script>
Which gives that error: “Uncaught ReferenceError: NLEntryForm_querySelectText is not defined”
b
id go for not setting the rec global if you dont want weird stuff happening
otherwise the more normal approach is to use Form.clientScriptModulePath to run code when netsuite expects custom code
c
Thanks. I actually got it working. Turns out I needed to wait for the DOM to be ready. Will check out that client script module path though