This took me a number of hours to finally figure out so sharing to help save precious life hours - I hope someone benefits.
Passing data between “Reusable Elements”
Use case - I have a menu dropdown menu that triggers a slide out display with forms that correspond to the selected dropdown item
E.g - I select - Add new company from the menu, the slide out opens and the form to add a new company is present.
OR
I select - Add new contact from the menu, the same slide out opens but conditionally shows the new company form instead based on the data.
Each of the above is a reusable element on a page with data passing between them both.
How did I achieve this?
Step 1.
In both of your reusable elements create a custom state on the reusable element parent that’s similarly named (I did this to help match it up easily).
Step 2.
Add both the reusable elements into the positions on the page where they are needed.
Step 3.
Open the first reusable element that is sending the data to the next, in my case the drop down menu item.
In this element find the second reusable element, in this case the slide out element. Ensure this is hidden, width minimised etc.
This is not used for anything other than the data connection so the first reusable can ‘see’ it.
Now… in my case i want a menu items option set to be saved in the first RE (reusable element) and transferred to the second RE.
To do this I save the click on the item as a custom state, like below - you will obviously want to do whatever you need… step 4 is the magic.
Step 4
Go to Workflow (we are still on the same reusable element).
Click on “add event” - Custom = “Create custom event”
Name it something
Now Element actions set state
Now set a stat of the target item, in my case the slideout menus element and the custom state that we set up in Step1 to be the value of the step 3s custom state.
Step 5
Now the end op the road, on step 3 where you set up the workflow to capture the initial menu options state, add a new item
Trigger custom event - this will default to the only one you have if you have it.
Boom … you are done … test and away you go.