Hi all! Any ideas why `runtime.getCurrentScript()....
# suitescript
k
Hi all! Any ideas why
runtime.getCurrentScript().getParameter({ name: 'custscript_myparameter' })
would return null when there's a value in the deployment for that parameter?
c
I'm sure you have but i'd double check the ID. The code looks OK.
a
yup code is good, bad param name is the obvious thing to check... making sure runtime is defined, but that would give an error... any conditional code that maybe isn't running?
k
Nope, param name is identical
I even copy pasted it from the param in the deployment to the script to make sure
also tried without the object argument syntax:
.getParameter("custscript_myparameter");
Same result though.
a
right the problem isn't that line of code
its something else somehow
either some code before that point, or something with the script deployment I'd say
or you've typoed on the variable name
Copy code
const myVar = runtime.getCurrentScript().getParameter({ name: 'custscript1'});
log.debug({
    title: 'my log'
    details: myvar
});
c
i'd just remove everything else in the script and just have it get the param and log it out and see if its getting the value. If so, you have an issue elsewhere .
k
Good suggestions! i'll try those after my current test
Right now I've just added another parameter that's plain text and seeing if I can get that
the parameter that's failing is a date field
b
the task module can overwrite parameters script parameters
caching related issue can effect parameters though thats more common with user and company level preferences
k
it's not using task though, this is a scheduled map / reduce
b
are they being started via N/task
k
no, it's being started through the UI
also thought maybe it's the scheduling that's the problem so I just unscheduled it, same result
on the other hand, my text field works perfectly!
so, why does the date field parameter come through as null?
a
what value does it have?
k
my text parameter custscript_test returns "test 123" which is the value of the parameter
my date parameter custscript_myparameter returns NULL but its value in the UI is today's date, picked from the calendar on that field
a
trying to recall if I've EVER used a date for a suite script param... I don't think I have, when I've needed to use date params I do them as strings
k
closer, doing typeof on it returns an object
let's try N/format
b
the type of null is object
k
drat, you're right
I should have thought of that
is there a way to get all parameters and their contents?
or do you have to know the names ahead of time?
c
just make it a text field and take that value into N/format to get your date if all else fails
just put the format you're expecting in the label or desription
its a script parameter its probably not getting changed too often (could be wrong). Make it easy on yourself
k
it's a script I inherited (just started with this client). Their previous developer / admin had set it up to bulk invoice quarterly, and the business requirement was originally that the AR folks would be able to run it by setting the date in the script parameter then run it
the previous developer obviously never got it working
I have it running right now with the text field approach
💯 1
hopefully this is the only issue. fingers crossed
fingers crossed 2