...
2. Use JavaScript Runner to get the data
Type Insert a JavaScript Runnet at the top of a new Confluence page and type following script in the body of JavaScript Runner the macro
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var yahooFinanceQuery='https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback='; var yahooFinanceData=JSON.parse(http.get(yahooFinanceQuery)); var apple=yahooFinanceData.query.results.quote[0]; var google=yahooFinanceData.query.results.quote[1]; var microsoft=yahooFinanceData.query.results.quote[2]; context.set("google",google); context.set("microsoft",microsoft); context.set("apple",apple); |
...
6,7,8: Use context object to attach those variable to this page context so other Javascript Runner macros in this page be able to access those
2. Use varibales attached to the context
Now we will create a table and inside each table cell we will insert a JavaScript Runner macro calling the property we need
3. View the Dynamic Table
The table's data will be updated each time page loads, in this example the stock price per share will get updated