I want to have a Form Level Script (DoSomething) that accepts an input parm ex DoSomething(‘abc’).
I’d like to call this script from various field level scripts using runScriptNamed(‘DoSomething’) but I do not see how to pass the value of ‘abc’ into the script on the runScriptNamed call.
Is it possible?
Thanks
Bernie
If you setup a variable and populate it before you call runScriptNamed()
then you should have access to that variable from within the script you’re running. So no parameter required.
you mean the Form Script will have access to a variable declared in a Field Script function ??? are all your vars global? this sounds strange to me.
What I understand is this:
function FieldScript() {
var xyz = ‘123’
form.rundScriptedNamed(‘formScript’);
}
Then in the Form Script:
function formScript() {
var abc;
//I can set abc = xyz
abc = xyz;
// and now abc will have ‘123’ in it ?
}
This doesn’t make any sence to me thinking about rules of encapusalation. Unless there is some type of ‘Global’ tag I need to use on the variable.
Please help
Thanks
I use several scripts as infrastructure/include scripts. They only contain function or constant definitions. Then I use runScriptNamed()
to include these functions. Later, whenever I need, I can call one of these defined functions from these include files.
So for your example, define
function formScript(abc) {
console.log(abc)
}
Then from your calling script, you do
runScriptNamed("myIncludeScript")
and then later
formScript("hello")