cancel
Showing results for 
Search instead for 
Did you mean: 

Personas 3.0 SP6 - How to use JavaScript global libraries?

former_member238607
Participant

Hi,

I've been using global libraries for JavaScript since at least SP4. We've installed SP6 in our Sandbox, and it's causing a number of JavaScript issues. Mainly because the standards are stricter in SP6 than they were in the past. For instance, it now flags 'Alert' as an error.

I've been able to modify most of my code to resolve the issues, but one item I haven't figured out is how to continue to use global libraries. The code below works fine through SP5, but it won't run in SP6 as it says Shared_Library is not defined.

if (window.Shared_Library === undefined) {
  Shared_Library = session.utils.include("005056AA160B1EE798B27D95FD08669D", true);
}

var mainContainer = session.findById("wnd[0]/usr/subPersonas_149554237315683");
var titleBar = session.findById("wnd[0]/usr/txtPersonas_149027319810573");
var lesLogo = session.findById("wnd[0]/usr/imagePersonas_149028455472754");

Shared_Library.formatHeadingBasedOnWidth(mainContainer, titleBar, lesLogo);

I've tried defining the shared library using session.utils.put, which removes the errors on the first few lines, but it still says Shared_Library is not defines, and the script will not execute the formatHeadingBasedOnWidth command.

Has anyone dealt with this issue, or does anyone have any ideas on how to get this to work in SP6?

Thanks for your help!

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member238607
Participant

Hi Chris,

My libraries are set up like the example near the bottom of that wiki (the one that says "Table Control Library that will Work on all GUIs").

I was basically accessing it as shown in the wiki as well, except I was (I believe) storing them in a global variable instead of a local variable. If you look at the code in my initial post, I'm checking to see if the library variable exists and only loading the variable if it does not.

My JavaScript research had indicated that variables defined with 'var' have a local scope, while those defined without 'var' have a global scope. However, it also states that global variables are not created automatically in 'Strict Mode'. SP6 is display a number of errors in my scripts that didn't show as errors in SP5, so I'm assuming SP6 has implemented the strict mode.

So now I'm trying to find a way to create global variables under SP6. I could switch my code to use a local variable by adding 'var', but this seems like unnecessary overhead to load the global library every time my script runs (it's in a onLoad event). I tried to use the session.utils.put command to store my library in a session variable, but that generates an error saying the put value needs to be a string.

Any other thoughts on how I can storie the library in a global variable?

Thanks,

Jeff

cris_hansen
Advisor
Advisor
0 Kudos

Hi Jeff,

Please check this wiki page.

Let me know whether it worked for you.

Thanks and regards,

Cris