Accessing an output from a Reusable Element?

Hey is there any way I can use a reusable element and then access one of its fields?

Like I pass input to it and it does its magic displaying lots of stuff then I get one of its fields showing on the screen??

You can access custom states of the reusable element from outside.

You can use a combination of Custom States, Properties and Custom Events to pretty much do anything you like.
Can you be more specific about what you are trying to do?
Are you trying to show a value on the screen or access the value from a workflow/element on the page-level?

Properties Custom States work very similarly, the main difference being how easily they can be set/accessed.
Custom States - Easily accessed from page-level OR reusable-level elements, however they are more complex to dynamically set.
Properties - Easily dynamically set from the page level and handles Reusable Elements placed in Repeating Groups infinitely better than trying to use custom states, but properties can’t be changed at the Reusable Element level.

Now that we can ‘Return data from custom events’ Custom Events are where the magic can truly happen.
On the page-level you can use the workflow block ‘Trigger a Custom event from a Reusable element’. This will allow you to return anything from the Reusable Element on a page-level workflow.

So what exactly is the magic/processing you need to do and why would you like to put it in a reusable element?

1 Like

For example

let’s say we have 2 inputs. on my page.
Then I call a reusable element and pass it the 2 inputs.
In the reusable element has 1 input and its the sum of 2 the numbers.
How can I access the reusable element input from the page?
(just a made up scenario)

This is a simpe task and will have multiple possible solutions, but here is how i would do it.

Create an RE
Add two properties on the RE of type number
Add a Custom Event on the RE
Add a Return value on the Custom Event of type number
On the custom event, use the ‘return data’ workflow and return Property 1 + Property 2
On the page, add your RE and set its properties to the two inputs values. (You could instead input custom states and dynamically change their values to different input elements, so you can use the same RE for any set of values, not only input A and B. )
On the page level, add an ‘input value is changed’ worklfow targeting both Inputs.
In the workflow, use the ‘run workflow from a reusable element’, and you can then set a page-level custom state to the result of the custom event.

This topic was automatically closed after 70 days. New replies are no longer allowed.