Set Text on a Widget using a Global Variable name


I want to use the NAME of a Global Variable to do stuff. As I’m testing, I’m learning better ways to name things. As such, there are times where I’m using naming conditions (Item.X within a repeater) to drive things. If I change the label of something, any conditions I’ve written get lost.

I’d like to name the Global Variables I’m already using to pass that information. So, Global Variable:

Name: Johnny; Value: 10

On Load, set text on (label widget) equal to "Global Variable NAME of [[Johnny]].

If Johnny later changes to Jonny, etc., everything I have still works…in theory. :smiley:


Hi @JoeDte, thanks for writing in! Unfortunately, currently, we don’t have an action that allows you to set up the name of the global variable. However, I’ve submitted a feature request for our product team. As a next step, they will take a look at it and define if this change can be implemented in future releases. Thank you for bringing this to our attention!


In a general programming sense, and certainly in Axure, this shouldn’t be necessary. The name of a variable is known to the program/programmer, and is static. If you plan to reuse it or its purpose changes later on, then it is best to name it accordingly. For example, something like “Username”, “User01” or “temp1” instead of “Johnny”. It is probably easier to just use two global variables, one for your “dynamic name” (e.g., “Johnny” or “Jonny”) and another for the true value (e.g., “10”).

Since dynamic variable names are not supported in Axure (yet, pending new feature per Axure Support) one way to achieve this with a single variable would be to code the “dynamic name” of the global variable into its value, and then use a delimiter to separate that from the true value. It’s not perfect, and you still can’t directly refer to the dynamic name, but it does work. Effectively, you’d have two values for your global variable (which is pretty much what a dynamic variable is in Javascript anyway.) For example, if you used a semicolon as a delimiter, you could set up:

  • Global Variable: User01
  • Dynamic Name: Johnny
  • Default Global Variable value: Johnny;
    (set from the Auxre RP menu item Project > Global Variables…)

Using the global variable (setting and getting) becomes more cumbersome (so again, likely easier to just use two global variables instead) but maybe not too bad with judicious copy&paste… You can make use of the substring() and/or slice() functions (more or less interchangeably.)

  • To set the true value for “Johnny” to “10” use:

Set Variable Value
User01 to “[[ User01.slice(0, User01.indexOf(’;’)+1) + ‘10’ ]]”

  • To get the true value, use the expression:

[[ User01.slice(User01.indexOf(’;’)+1) ]]

  • To set the text of a widget named, MyWidget, to the dynamic variable name use:

Set Text
MyWidget to [[ User01.substring(0, User01.indexOf(’;’)) ]]

// the semicolon ( ; ) is used as a delimiter between the dynamic name and true value. You can replace it with any char or string–just be consistent with whatever you use and make sure it is not used as part of your dynamic name or any possible true value.

Here’s a quick demo: Dynamic Global Variable Names.rp (55.2 KB)


Thanks for the reply. You’re always helpful.

In this case, though, I’m using 27 GV’s already to hold values for a Cart repeater function. Adding 27 more to drive the text…not as good as just using said text, even though I’m sure you’re correct about the programming note.