cancel
Showing results for 
Search instead for 
Did you mean: 

Personas: Is Personas 100% compatible with Javascript?

Former Member
0 Kudos

Hi Personas experts,

In a ScriptButton, one can write JS codes in "Calculate in Javascript" tag.

I am wondering if I can write any JS codes here? What is the limit of JS codes that Personas does not support.

Another example issue is how the scope of a so-called "global variable" is inside Personas. Inside a Scriptbutton, one can use "args.myVar" to refer to a "global var" "myVar" through the actions in teh same button. But when refering to this var from other Scriptbutton, it seems that .myVar is not defined. Why?

Thanks.

Dong Zhu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

"args" is an object created by the Personas script engine and passed to your script. It contains all the variables created, by for example Copy Value, in other steps in the script. The variables in there do not persist once the script has finished. In particular, you can't reference them in scripts on other script buttons.

Now if you create JavaScript global objects - either explicitly inside the "window" object or implicitly - they will persist, and can be used by scripts on other buttons, and even by scripts in flavours on other transactions. They persist until you refresh the browser window.

See my blog for a way to make use of this.

As for what else you can do in a JavaScript action, probably you can do most things. If you have some ideas - try them and see what happens! Interaction with screen objects isn't so straightforward, though...

Former Member
0 Kudos

Hi Steve,

Thanks for the info. So basically the JS code has a scope within a Script Button unless a sort of global obj is used (eg window obj). I guess the only way of passing values between script buttons would be use of "Text Box" using Copy Vlaue and Paste Value.

By the way, do you know any way of embedding jQuery in Personas?

Thanks again and set yours as Correct.

Dong Zhu

P.S. Likely see you at TechEd Berlin Nov. 2014

Former Member
0 Kudos

Yes a JavaScript action is basically wrapped in an anonymous function and then called. The variable scoping then works as you'd expect.

The standard way of passing values between script buttons is via hidden text boxes, copying and pasting as necessary. That can get a little tedious if you do a lot of it. As I said, you can store values in the global window object and access them from any Javascript action, in scripts on different buttons or even on different flavours, so long as the browser window isn't refreshed.


I'll be at many of the Personas related sessions at TechEd - feel free to say hello .


Steve.

Answers (0)