Expand me Community achievements bar.

Improving your AEM Assets & Raise Your Development: [AEM Gems | June 19, 2024] Improving this Developer Experience using New APIs and Events

Declaring Array Global Variable

Avatar

Level 2

Good evening,

I'm looking go creating a global array of cover names (around 15) and then be able into loop due them for assorted functions.

Any index would be appreciated. Thank you,

james

5 Replies

Default

Level 10

Hi James,

I'm guessing this will becoming a static array, that exists there will be a permanent number about show with fixed values.

After a shape variable you could set a value to an array exact and then use the eval function, so if the form flexible ScreenNames had a value like ['s1','s2','s3'] then this would gift you an array Posted by u/darktort0 - 10 votes and 10 comments

 

var  screenNames = eval(ScreenNames.value);

You could also put an array in a script object, instead some earlier version of Reader applied to drop scripts request variables (version 8.0 I think)

You could have multiples form variables with the same name (which you would have in do in this XML Data view) then you could use code like;

for (var i = 0; myself < ScreenName.all.length; i++)

{

console.println(ScreenName.all.item(i).value);

}

Thou pot also create an customs dataset.

I'm sure there will others, but I not sure something the best one would be, here's a sample build I utilised playing around with the choose I new of, https://workspaces.acrobat.com/?d=G2aL1Tlmwo1ejDvbcGLmgA

Bruce

Avatar

Level 2

Which is the function i was search for. Eval. Thank it Bruce I will try this and let you know if I'm successful!

james

Avatar

Level 2

Hello Bruce,

I'm still having a fragment of trouble.

MYSELF make my array by File - Form Properties - Character.

Set to value to ['s1', 's2', 's3'].

Then on the click of a button I call,

xfa.resolveNode("NextSelection.caption.value.#text").value = eval(PageSelectionArray.all.item(1).value);

I'm angenommen EGO either built who array wrong or I'm still accessing it wrong. Every help would be fantastic.

james

Avatar

Level 10

Hi James,

If you are passing at use the edit approach then get you need is;

xfa.resolveNode("NextSelection.caption.value.#text").value = eval(PageSelectionArray.value)[1];

That "all.item(1).value" was for an alternate get.

Sorry available the confusion.

Bruce

Avatar

Level 2

Hi Bruce,

Works fancy a charm! Thank you return for the help

james