Use a repeater to set a reference page link (not open the page directly)

repeater-widget
newbie-question

#1

Hello,

I have scenario where I have a repeater table with various reference pages in the repeater. I want to select an item in the repeater, but only open the selected item’s reference page when I click a CTA located outside of the repeater. Is there any way to do such a thing?


#2

Two methods I know of to do this. They can work any time you need to trigger an event/action in a specific row in a repeater. Here is a quick demo showing both…
repeater ref page from outside.rp (78.9 KB)

Assign a “listener event” to a widget in the repeater.
When this event is triggered from outside the repeater, every row’s widget will get triggered in rapid succession from first to last row. Create some logic to identify the correct row and test for it in a conditional case so that only the targeted row(s) will work. In this way, each row will “listen” for a “signal” to “hear” if it is the correct targeted row.

  • Choose or create a widget in the repeater. Choose an event that is otherwise unused and wouldn’t be accidentally triggered, like Moved or Rotated.
  • Assign your action.
  • Add a conditional case that listens for the signal. For example, a global variable value (or text value of a widget outside the repeater) could be set to the row’s index number, or a text value in the repeater’s datasheet like a name or ID, e.g.,

MOVED
Case 1
If value of OnLoadVariable equals “[[Item.First_Name]]”
Open Link
[[Item.MyRefPageColumn]]

…be sure to clear the signal value if doing something other than loading another page

  • From outside the repeater, on your CTA, set your “signal” value, then trigger this event, e.g.,

CLICK OR TAP
Set Variable Value
OnLoadVariable to “Vanessa”
Move
MyRepeaterWidget by (0,0)

…thus no actual movement, just a way to fire the event and cause its conditional case to be evaluated.


Update Repeater, targeting a row with a rule
You can use Edit Row Data event to specify which row(s) you want to target, with a rule, row index number, or marked rows. Set up a column in the repeater’s datasheet to be updated and a way to handle it in the repeater’s Item Loaded event.

  • Assign a column in the repeater’s datasheet to handle a targeted row, e.g., “TargetColumn”. Keep the default value for all rows blank.
  • Create a conditional case in the repeater’s Item Loaded event that tests the value of the “targeting” column, e.g.,

ITEM LOADED
Case 1
If [[Item.TargetColumn]] equals “true”
Open Link
[[Item.MyRefPageColumn]]

  • From outside the repeater, on your CTA, update the repeater, targeting a specific row (or mulitple rows), e.g.,

CLICK OR TAP
Edit Row Data
MyRepeater set TargetColumn to “true” where “[[Item.First_Name == “Vanessa”]]”

  • Thus, a row with “Vanessa” as the value in its “First_Name” column will be updated to have “true” as the value in its “TargetColumn” column. This update causes the repeater to be rebuilt, triggering the Item Loaded event, which in turns triggers the actions.

#3

Thank you for your detailed reply!

I actually worked some more on it after I posted and came up with basically the second method you suggested, using marked rows.

Now, however, I have another condition which I could not solve - If nothing in the ‘selected’ column is chosen, I want to show a message when the button is clicked. Is there a way to do this without a global variable?

Please see my attached example

Reference Page.rp (73.0 KB)


#4

In general, the only time you absolutely need a global variable is when you need to access data across pages. Within the same page, you can always use the text value of a widget on the page, whether it is hidden or shown, instead of a global variable. In your situation here, you can also use an interaction state to test against. I updated your file to show a few different solutions. Use whichever makes the most sense to you.

Reference Page.rp (92.0 KB)

Looking at your rp file, it looks like whenever any row’s “selected” column is “1” it loads that row’s reference page. So there is no possible way to test for “selected” values when clicking the “Go To Page” button, because 1) that button assigns a value of “1” to all marked rows; and 2) When a row’s value for “selected” is 1 it automatically changes the page. So, with your scheme as you have it, you need to test for the condition of “no rows are marked”.