Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Referencing "Form Variables" in Formcalc

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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");


View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

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");


Avatar

Level 2

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

Avatar

Level 2

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

Avatar

Level 10

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.