When adding a button on a Client Script record, wh...
# suitescript
d
When adding a button on a Client Script record, what would cause it to not find the function? Am I doing something wrong here?
r
Missing your exports
s
Typo in the clientscriptmodulepath?
d
@Robert Vice What do you mean missing exports? That's what the return is or am I needing something else?
s
No, I would also try changing to 2.0 explicitly
d
@Sandii I thought about that but my library I want to use is 2.1. 😞
r
I'm using typescript and deploy, it adds "exports.<function>" near the top
Copy code
exports.saveRecord = exports.pageInit = void 0;
Just chained along
s
You don't have to use exports, it's just an object that you return. What he has done is the same thing by returning the object directly instead of creating it at the beginning
✔️ 1
I don't think it should matter but you could try changing the syntax of setBatch to something like
const setBatch = () => {}
. Otherwise I would double check your button initialization and make sure nothing looks off there
r
note, are you using a User Event script to create the button? Or did you add a button and attach this client script to it?
d
changing syntax didn't work
This is strictly a client script using the button feature on the script record.
e
How are you calling setBatch from the UE?
d
It's not a UE, just Client Script (see initial pic)
s
I've literally never used the button feature on script record 🤷‍♂️
d
I've used it several times and can reference another one of them but for some reason this one is not working. I just can't figure out why. It has to be something stupid simple or it's NetSuite....
b
id remove the button and then add it again, making sure there arent any extra characters in there
d
That didn't work either. I'll be pissed if this works tomorrow after letting it sit a day with no change.
b
meh
cheat and set setBatch on the window global
d
I know I could just do it another way but this should work. Why it's not is pissing me off.
e
You query string is using backticks. Shot in the dark but I think I ran into that and client 2.1 scripts.
d
No luck with that either.
b
that actually might work, use 2.0 instead of 2.1
d
@battk Yep, switching to 2.0 worked. Not sure how to handle this when the library needed (not shown here) is 2.1
b
conditionally require it
d
So glad NetSuite is consistent with everything
b
you only need to require it when your code is running in a browser
so basically only if the window global is defined