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
BedrockMission!

Learn More

View all

Sign in to view all badges

array in global variable

Avatar

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
eugzl
Level 2

10-04-2018

I'm trying to figure out how to use global variable array. I found post

myArray is not behaving as GLOBAL scope?

I did exactly like explained in that post. But when I click button I got such error message result:

JS_global.png

How fix it?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

10-04-2018

Ah, I found the answer in your second thread.
Well, to create an global array, create variable in the form properties. 1462458_pastedImage_0.png

Then add a script in the initialize event of the forms root node (i.e. form1).

aGlobal = eval(Global.value);

1462459_pastedImage_1.png

Now, you have access to the global variable by JavaScript.

// load the fist array item into a text field

this.rawValue = aGlobal[0]; // returns John

Answers (2)

Answers (2)

Avatar

Avatar
Validate 10
Level 5
tarekahf
Level 5

Likes

32 likes

Total Posts

409 posts

Correct Reply

10 solutions
Top badges earned
Validate 10
Validate 1
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Validate 10
Level 5
tarekahf
Level 5

Likes

32 likes

Total Posts

409 posts

Correct Reply

10 solutions
Top badges earned
Validate 10
Validate 1
Give Back 50
Give Back 5
Give Back 3
View profile
tarekahf
Level 5

11-04-2018

Thank you radzmar ...

I always wanted to do that, I mean using Form Variables to store global variables with different types such as objects and arrays. Using eval() is the answer.

Also, mind you that you can use uneval() to store the variable back into the form variable. Use this method if the variable is not simple type (number or text).

Also, you can use "extras" section under any field or variables section under any subform to create and store variables almost in the same manner. This can be done in XML View or using javascript.

See this post for more details:

Form Variables

Tarek

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

10-04-2018

What do you need the global variable for?