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

Get a list of all variables used in a project in a console

Engaged ,
May 16, 2018 May 16, 2018

Copy link to clipboard

Copied

Hi there,

hopefully this has a short answer.

How can I open the developer tools with F12 and in the console get a list of all the custom variables that I have used in the project?

Thank you in advance

B

Views

520

Translate

Translate

Report

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

correct answers 1 Correct answer

People's Champ , May 17, 2018 May 17, 2018

This will show all of the custom variables and their values. If it does not have a value, it will be blank.

var myVars = cp.ReportingVariables.split(",");

     myVars.forEach(function(vars) {

      console.log(vars+" = "+window[vars]);

     });

Votes

Translate

Translate
Community Expert ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

Hi,

Please confirm that your are using a Windows OS and F12 relates to Internet Explorer.

You will see the list of variables in your Captivate interface.

I would expect the server to process the values/variables before it arrives at the browser (server side).

Votes

Translate

Translate

Report

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
Engaged ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

Thanks for your reply Eric

Yes, I use Windows and IE.

My goal is to be able to get a list of all variables in the console of the browser, not in Captivate

Votes

Translate

Translate

Report

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
People's Champ ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

Do you just want to see the variables or their values also?

Votes

Translate

Translate

Report

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
Engaged ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

Thanks David

I know how to get the values once I get the names, so I would like to get a list of the (custom) variables in a project.

Votes

Translate

Translate

Report

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
People's Champ ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

This will show all of the custom variables and their values. If it does not have a value, it will be blank.

var myVars = cp.ReportingVariables.split(",");

     myVars.forEach(function(vars) {

      console.log(vars+" = "+window[vars]);

     });

Votes

Translate

Translate

Report

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
Engaged ,
May 17, 2018 May 17, 2018

Copy link to clipboard

Copied

LATEST

That is fantastic

Thank you once again! I am trying to understand the code., Would you please confirm it is correct? I have put comments after each line. At least about the bits that I understand.

var myVars = cp.ReportingVariables.split(",");      //here you are creating a variable myVar that would take the values of cp.Reporting variables and will split them after the symbol ",". I see the string that is returned by console.log(cp.ReportingVariables). myVar is actually an array

myVars.forEach(function(vars) {        //here you execute the method forEach for the myVar array which will execute the function once for each element of the array. Would you please explain more about the function(vars) bit? Are you declaring vars as a variable inside the function?

console.log(vars+" = "+window[vars]);     //the function would execute console.log and will add the "=" between the variables and the actual value of the variable. Would you please explain with a few words what is the difference between vars and [vars] - one is the name of the variable and the other the value?

});

I am trying to make sense of the code too...

Thanks

B

Votes

Translate

Translate

Report

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