WIth LiveCycle Designer ES4 I'm trying to place a group of string variables used throughout my form so as not to have to edit the same variables in several places.
I don't want to use Form Properties>Variables because one can't see the entire group at once. In other words, there are variables that need to be located next to subordinate variables for a clearer picture and to prevent errors, i.e. var propertyOwner, var propertyTract, var propertyTelephone.
Under variables in the form hierarchy, I inserted a "Script Object" folder and named it "Owners". In that folder I entered all of the mentioned variables. The folder/object name is "TwentyTwoHills.#variables[0].Owners". The first variable is
var TTHOwner1 = "Joe Smith";
How can I reference this variable to be used to load a drop down box in my form with FormCalc?
Any help appreciated,
Thanks,
Fred
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
in script objects you only can use JavaScript syntax, FormCalc in not supported by these objects at all.
As you also cannot call an JavaScript action from a FormCalc event.
You'll have to use JavaScript in all scenarios you're using the script objects.
Here's a sample how to do this.
Create a function in your script object, that contains some nested arrays.
Each array contains two values, the first represents the name the second the value.
Through the forEach method you can simply filter the arrays.
function loadValue (vValue){
var aVars = [
["varA", "Lorem"],
["varB", "Ipsum"],
["varC", "Dolor"]
],
vReturn;
aVars.forEach(function (element, index) {
if (element[0] == vValue) {
vReturn = element[1];
}
});
return vReturn;
}
Retrieve the value from array "varA" use this function.
Owners.loadValue ("varA");
Views
Replies
Total Likes
Hi,
in script objects you only can use JavaScript syntax, FormCalc in not supported by these objects at all.
As you also cannot call an JavaScript action from a FormCalc event.
You'll have to use JavaScript in all scenarios you're using the script objects.
Here's a sample how to do this.
Create a function in your script object, that contains some nested arrays.
Each array contains two values, the first represents the name the second the value.
Through the forEach method you can simply filter the arrays.
function loadValue (vValue){
var aVars = [
["varA", "Lorem"],
["varB", "Ipsum"],
["varC", "Dolor"]
],
vReturn;
aVars.forEach(function (element, index) {
if (element[0] == vValue) {
vReturn = element[1];
}
});
return vReturn;
}
Retrieve the value from array "varA" use this function.
Owners.loadValue ("varA");
Views
Replies
Total Likes
Thanks, I understand how that would load variables and make them available to a JavaScript event in the form. What I'm after, however, is a global variable that one could use in either a JS or FormCalc event without using File>Form Properties>Variables. Maybe this can't be done.
Thanks for your response,
Fred
Sent from my iPad
Views
Replies
Total Likes
At this point, I've concluded that you can't have global variables available to both JS and FormCalc other than File>Form Properties>Variables. I converted my scripts to JS and implemented your suggestion to use Function loadValue. It works great!
Thanks,
Fred
Views
Replies
Total Likes
Ok Fred, sorry for the delay.
FormCalc is not an object oriented language as JavaScript is, so it has no mechanism to deal with global data in variables or in arrays.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies