Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Referencing a script object in another script object

Avatar

Level 3

Can I reference another script object in a script object? All script objects would be under the same Variables hierarchy.

I have a dropdown field.

In the 'exit' event, the first reference:

DropExit.Exit1(this);

In the DropExit script object:

function Exit1(current)

{

if(Drop.rawValue =="1")

{Color1.presence = "visible";} else {Color1.presence = "invisible";}

if(Drop.rawValue =="2")

{Color2.presence = "visible";} else {Color2.presence = "invisible";}

}

No problems!

But, I would like to do something like this:

function Exit1(current)

{

If(Drop.rawValue == "1")

Selection.S1(this);

If(Drop.rawValue == "2")

Selection.S2(this);

}

then I would have another script object,

Selection script object:

function S1(current)

{

{Color1.presence = "visible";} else {Color1.presence = "invisible";}

{

function S2(current)

{

{Color2.presence = "visible";} else {Color2.presence = "invisible";}

}

in my little mind, this seems like it would work... is it possible?

Thank you in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 7

I would think if you have multiple script objects you might need to be more specific with it's reference.

For Example:

1525502_pastedImage_1.png

If i was working in my script object vars but wanted to access my function in moreVars, it would be referenced like this:

moreVars.profileCount();

I dont know if thats what you were after.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 7

I would think if you have multiple script objects you might need to be more specific with it's reference.

For Example:

1525502_pastedImage_1.png

If i was working in my script object vars but wanted to access my function in moreVars, it would be referenced like this:

moreVars.profileCount();

I dont know if thats what you were after.

Avatar

Level 3

Brilliant! This is exactly what I need!

Thank you!