Work with global variables


#1

Hello everyone,

I’m testing Axure RP to see if it meets my needs. One of my tests involves using global variables and JavaScript. Unfortunately, I’ve encountered an issue related to the $axure object and getGlobalVariable. I can set the value of a global variable using $axure.setGlobalVariable() (in JavaScript) and get it using UI interactions, but I can’t set and next get the variable’s value using JavaScript functions.

The same issue was mentioned in this post, but nobody has answered yet. Worse still, this issue has existed since Axure 9.

In short, getGlobalVariable should have a “return” command. It looks like developer typo.

  1. Is it possible that the $axure object is deprecated and should not be used?
  2. I can’t find any documentation on $axure object. Using the application’s name as the name of the main object doesn’t help when searching for additional description.Is somewhere the documentation of $axure object ?

Thanks


#2

Haha, That’s my post.

You can fix it yourself, run once this code first:

$axure.internal(function ($ax) {
    $ax.public.getGlobalVariable = $ax.getGlobalVariable = function (name) {
        return $ax.globalVariableProvider.getVariableValue(name);
    };
});

and then use:

console.log($axure.getGlobalVariable('OnLoadVariable'));

#3

This is a great idea, but it means that I have to do this every time I reload the mockup. Of course, it isn’t a huge problem, but still strange :slight_smile:
Have you tried contacting support about this issue? I will send an email to support tomorrow.


#4

For those who may seek this in the future:

I’m afraid that what you’re attempting to achieve may have been depreciated with Axure RP10. You may have some success in Axure RP9, but code of this particular nature is largely unsupported.

A forum user has put together some documentation on the functions you are using at the moment, but please note this comes from a 3rd party so we cannot guarantee that this information is correct. http://www.dejongh.dk/wiki/doku.php?id=interaction:axure_api

That’s the answer I’ve got a month ago from the support.