I know I must be doing something dumb. Trying to ...
# suitescript
m
I know I must be doing something dumb. Trying to use a Script Parameter on a Scheduled Script for the saved search that it loads. I'm using
Copy code
var savedSearchParam = runtime.getCurrentScript().getParameter({
		name: 'custscript_test_param'
	});
but when i log it, it returns null. What am i doing wrong?
k
from this i cannot see a problem.
Not unless the script parameter on the deployment doesnt exist yet.
m
does it have anything to do with it not being scheduled and just executing it on demand?
k
no shouldnt be
param still exists
When you log are you getting any errors?
Do you ahve your code in a Try Catch?
m
no errors. i do not have a Try Catch
k
Cannot see why it wouldnt work then. Do you have the runtime module loaded in the define?
m
yep. Im using it to get usage
e
How are you triggering it on demand? Is the Script Parameter set to Store Value?
s
Is the Preference of the Script Parameter blank or set to User / Company?
m
Preference is set to Company. I've triggered using Save & Execute on the Script Record and the Deployment Record. Script Parameter is set to Store Value.
k
That would be why
You would need to get from Company prefs not the script.
s
So you should update the field value on Setup > Company > General Preferences
and use
config.load
to get the value from Company Preferences
k
config.load({type: config.Type.COMPANY_INFORMATION});
s
not
config.Type.COMPANY_INFORMATION
but
config.Type.COMPANY_PREFERENCES
k
Yeah my bad sorry
copy paste is failing in this instance.
m
That did it! Thank you everyone. My first Script Parameter (in case you couldn't tell)
s
this should do the trick considering N/config module is loaded 😉
var companyPreferences = config.load({
type: config.Type.COMPANY_PREFERENCES
});
var savedSearchParam = companyPreferences.getValue({
fieldId: 'custscript_test_param'
});
k
HAHA @Selcuk Dogru COMPANY_INFORMATION
copy paste strikes again!!
s
oh 😄
m
👍