Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

What are the options to clone image/list/checkbox objects?

Avatar

Level 2

Hi,

I'm trying to clone one object and make duplicate of it using scripting in LC Designer ES2. one of these two use cases represent what I need to do:

  1. Reference an existing empty object (or unassigned/unset object) to the value of another similar object type. For example; I have an empty "image" object (imgObj1), I need to copy or clone the value of another image object (imgObj2) to imgObj1 to make imgObj1's values and attributes exactly the same as imgObj2. Another example, an empty list sould be dynamically filled through referencing (without going through looping) with the same values of another filled list.
  2. Create new object by cloning another object. For example, I need to create 4 new list object dynamically via scripting at run time (by clicking on a button for example) via cloning another list object.

I tried to use/understand the assigneNode, use, ref, clone(), etc... from the references, but the cases above it did not really worked out for me. The help documentation is not explanatory enough and/or do not have enough examples. Even the clone() method example shown in the help in ES2 does not provide enough example of other objects types.

Any help and support would be highly appreciated.

BR,

Yasser

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Yasser,

Here is a sample where the click event of the button assigns an image to an imageField:

ImageField1.rawValue = Image1.value.image.value;

The second sample uses addInstance() and removeInstance() to duplicate objects. Notice that the drop down is inside a flowed subform, with the binding set to repeat for additional items.

The forms must be saved as dynamic, otherwise the script will not work.

The script in the buttons uses shorthand for calling the instanceManager, "_" in front of the repeating subform's name. 

Hope this helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi Yasser,

Here is a sample where the click event of the button assigns an image to an imageField:

ImageField1.rawValue = Image1.value.image.value;

The second sample uses addInstance() and removeInstance() to duplicate objects. Notice that the drop down is inside a flowed subform, with the binding set to repeat for additional items.

The forms must be saved as dynamic, otherwise the script will not work.

The script in the buttons uses shorthand for calling the instanceManager, "_" in front of the repeating subform's name. 

Hope this helps,

Niall

Avatar

Level 2

Hi Niall,

Many thanks, it works very well, really appreciate your support.

The "image.value" part of your script can not be found in the Auto Complete in LC Designer ES2 when you start typing it!!!!

I strongly believe that Adobe must enhance its documentation and provide more and more basic examples on each method.

Once again, thanks for your support.

BR,

Yasser