Skip to main content
Nintex Community Menu Bar
Question

javascript noob Q - set global variables for current page

  • July 9, 2024
  • 2 replies
  • 24 views

Forum|alt.badge.img+20

Is this post correct? 

Can I set a global variable inline that is not within any function and use this variable anytime I choose so long as I don’t refresh the page?

For example, can I run a snippet which sets the value, so something in a popup, then run another snipper that used this global value.

2 replies

Forum|alt.badge.img+11

Pat,

With JavaScript, the global scope is the complete JavaScript environment.  In HTML, the global scope is the window object: All global variables belong to the window object.  So you could do something like this

var isDude = ‘Pat’;
alert(window.isDude);

-or-

if (!window.isDude) { window.isDude = 'Pat; }

Best practice is to not use global variables.

I am not a JavaScript developer so nothing said or written comes with an expressed warranty.

google-bing for lots of details and opinions.

Irvin


Forum|alt.badge.img+20
  • Author
  • Scholar
  • 2847 replies
  • July 9, 2024

I wouldn’t use a global variables in snippets could take in parameters when being called from an action.