Hi everyone, I just wanna confirm if it would be p...
# suitescript
r
Hi everyone, I just wanna confirm if it would be possible to fire a user event script upon adding a line in a sublist?
m
Just upon saving the record, not directly upon adding the line.
r
what would you recommend to detect adding of a line in a sublist?
m
Why are you asking about a user event script? How is the line being added?
r
what I am trying to achieve is to check the line items upon adidng it. I had written a clinet script to use validateLine, however when I deploy this script, the sublist simply won't load.
m
Should it only work in the UI or should it also account for integrations and CSV imports or even other scripts doing something in the background?
r
I just need it to work for the UI. upon adding an item for transfer order to be exact.
m
So a UE will not work. Needs to be CS.
Can you paste your CS logic code, please?
r
How do I go about the issue of the sublist not loading when I deploy the Client Script? I just have one event there which is a validateLine
"use strict"; /** *@NApiVersion 2.x *@NScriptType ClientScript *@NModuleScope sameAccount */ var mods = ['N/log', 'N/error', 'N/record', 'N/search', 'N/https', 'N/format']; define(mods, runClientScript); function runClientScript() { for (var _len = arguments.length, tools = new Array(_len), _key = 0; _key < _len; _key++) { tools[_key] = arguments[_key]; } log = tools[0]; error = tools[1]; record = tools[2]; search = tools[3]; https = tools[4]; format = tools[5]; return { validateLine: validateLine }; } function validateLine(type) { log.debug("context: ", type); }
m
was that just a trial to see if something would happen?
r
yes. just to log the type
m
Please change: function validateLine(type) { log.debug("context: ", type); } to: function validateLine(type) { log.debug("context: ", type.sublistId); }
r
still won't load
message has been deleted
m
Testing it on my system now.
ah
please don't define the runClientScript
That makes it run - and it fails
r
what do you mean?
m
define(mods, runClientScript); --> define(mods);
r
will try this
m
just a sec
Your file structure seems a little bit different to what I'm used to.
ah, got it now. Give me a minute
"use strict"; /** *@NApiVersion 2.x *@NScriptType ClientScript *@NModuleScope sameAccount */ var mods = ['N/log', 'N/error', 'N/record', 'N/search', 'N/https', 'N/format']; define(mods, runClientScript); function runClientScript() { function validateLine(type) { log.debug("context: ", type); } return { validateLine: validateLine }; }
However, that's not the logic you'd do on an item fulfillment.. you're not actually adding lines.
Care to have a call?
r
sure
appreciate it
m
Solved...