Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

passing variables between projects in Captivate 2017

New Here ,
Jan 18, 2018 Jan 18, 2018

This method used to work in Captivate 9, but try as I might, I can't get the following simple javascript to pass variables between projects in 2017.  Any ideas?  Something I could be doing wrong?

Project A:

window.localStorage.setItem('varname', window.cpAPIInterface.getVariableValue("varname"));

Project B:

window.cpAPIInterface.setVariableValue("varname", window.localStorage.getItem('varname'));

Any ideas why it wouldn't work in 2017?

TOPICS
Advanced
454
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 18, 2018 Jan 18, 2018

Is that the order you have it in? You are setting the variable in project before actually getting the value from local storage in project B....looks backwards in A too.

Brian Floyd

Director, Sales International Training Development

Behr | BehrPro | Masterchem

Bfloyd@behrpaint.com<mailto:Bfloyd@behrpaint.com>

Cell (920)377-0358<tel:(920)377-0358>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2018 Jan 18, 2018

Sorry, yes.

Project A:

window.cpAPIInterface.setVariableValue("variable", window.localStorage.getItem('variable'));

Project B:

window.localStorage.setItem('variable', window.cpAPIInterface.getVariableValue("variable"));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2018 Jan 18, 2018

I have also tried different syntax, which still doesn't seem to work.  I have tried it both in preview and by running it on my LMS in HTML5.:

A:

window.localStorage.setItem ( 'variable', window.cpAPIInterface.getVariableValue ( "variable" ) );

B:

window.cpAPIInterface.setVariableValue ( "variable", window.localStorage.getItem ( 'variable' ) );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 18, 2018 Jan 18, 2018
LATEST

Ok that all looks right now.  Couple of other considerations...If you are using chrome launch your course and press command opt J on mac or ctrl shift J windows.  This will open the debugging console. Find the tab up top that says application, and then choose local storage on the left and see if you have anything set there after when the A event is suppose to trigger.   You can then look at B and see if the value is still available when B is trying to get from local storage.

I am also guessing you understand that local storage is unique to each instance of a website.....I am not sure how an LMS launches content as I always host straight from my server, but essentially your 2 different courses would have to open from the same browser address for this to work.  I know that typically the LMS pops open a new window to launch content, so that window would have unique storage I believe unless it is an extension of the LMS.  If you had it working in the past though, I cant see why 9 to 2017 would make any difference, as it is basically just .js

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources