Need help updating repeaters Based on Global Variables

I am trying to create a repeater that changes the value of a single item between a price ($3.00) and “Free” based on a global variable. When the global variable is set to Yes, the item should be free. When No, the value should read a dollar amount.

It should be an easy thing to do, but I am still learning how to code in Axure. Any help would be appreciated.

GlobalVariableRepeater.rp (59.2 KB)


I changed the approach a bit. The variable name is now “freeItems” and its value is whichever item(s) you want to be free. Here the default value is “Grapes.” If you want apples to be free, you’d set it to “Apples” (matching exactly the name in the dataset, case and all). If you want both grapes and apples to be free, set the variable to “Grapes Apples” (space not required). And if you want nothing to be free, set it to any string that’s not a part of any of the names in the dataset. I chose “xxxxx.”

So now the logic in the OnItemLoad handler looks like this

IF True
    set text on name to [[Item.itemName]]  -- simply setting the text of the item's name here.
IF value of variable freeItems contains [[Item.itemName]]   -- checking to see if freeItems contains this item's name. Important: this is an IF, not an ELSE IF
    set text on Price to 0  -- since freeItems contains this item's name, set the text on Price to 0
    set text on Price to [[Item.itemPrice]]   -- no match: set it to the actual price

Note that the “Set Items per Page” command is there simply to force the repeater to redraw itself after changing the variable name.

File: GlobalVariableRepeater.rp (59.4 KB)

Oh - by the way, if you ever want to see what the value of all of your global variables are, hit the Console button at the left side of the prototype in the browser:

Thank you for your quick help and the very good explanation. It feels like I have been building things completely backwards from your example. It will take a while for me to understand it.
In the actual prototype, I will have 5 or 6 items that could have a discount of varying amounts. How would you modify this so Pineapple and Zucchini would be included in the sale and be $1.00 each?

Thank you,

Hi Jason,

It looks like Joseph’s file sets this up so as to allow multiple sale items. I went ahead and applied Joseph’s tip here:


This edited file includes the changes to the freeItems var and an updated dataset:
GlobalVariableRepeater_Edit.rp (58.5 KB)