Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set value in a variable of "use variables" using javascript in Klipfolio Dashboard?

I need to set data from HTML Component in a variable of Klipfolio using javascript as I am using a plugin for multiple selection from a dropdown box. I couldn't find any way to do that.

I tried with "set" method and other method, but it didn't work out for me.

like image 284
Sourav Mondal Avatar asked Jun 25 '15 11:06

Sourav Mondal


People also ask

How to use variables in JavaScript?

In programming, just like in algebra, we use variables in expressions (total = price1 + price2). From the example above, you can calculate the total to be 11. JavaScript variables are containers for storing data values. All JavaScript variables must be identified with unique names. These unique names are called identifiers.

Can I create a script to change the--blue variable?

Here is an example of how you can create a script to display and change the --blue variable from the example used in the previous pages. For now, do not worry if you are not familiar with JavaScript. You can learn more about JavaScript in our JavaScript Tutorial:

How do I set a variable in a request?

To create a variable at any scope from the request builder, select the data you need, for example in the address, parameters, headers, or body. Choose Set as variable > Set as a new variable. Enter a Name, verify the Value and select a scope from the drop-down list. Click Set variable.

What is a variable identifier in JavaScript?

JavaScript Identifiers All JavaScript variables must be identified with unique names. These unique names are called identifiers. Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).


1 Answers

The dashboard has a function on it called "setDashboardProp". This function takes the following inputs:

  1. scope: (Values: 1 = Klip Scope, 2 = Tab Scope, 3 = Dashboard Scope, 4 = User)
  2. name
  3. value
  4. xid (klip or tab identifier)
  5. secondaryId (tab identifier) (when scope == 1, tab)

So to set a tab scope variable named currentMax to 10 use the following call:

dashboard.setDashboardProp(2,"currentMax",10,dashboard.activeTab.id);

Check that value was set using getDashboardProp:

dashboard.getDashboardProp("currentMax",2,dashboard.activeTab.id);

I would suggest using the browser console in developer tools in either Chrome or Firefox to test out these calls before including in a Klip.

like image 90
PedalCode Avatar answered Sep 29 '22 16:09

PedalCode