<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to set token value in the updateView using Javascript? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-token-value-in-the-updateView-using-Javascript/m-p/227270#M14099</link>
    <description>&lt;P&gt;Hi all ,&lt;/P&gt;

&lt;P&gt;Can you please help me how to set token value in the updateView? I have added my code.&lt;/P&gt;

&lt;P&gt;I know that am missing something ,  please help me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;// demoview 
define(function(require, exports, module){
    // Base class for custom views
    var SimpleSplunkView = require('splunkjs/mvc/simplesplunkview');
    var mvc = require("splunkjs/mvc");

// Define the custom view class
var DemoView = SimpleSplunkView.extend({
    className: "demoview",

    // Change the value of the "data" property
    options: {
        data: "results"
    },

    // Override this method to configure your view
    // This function must return a handle to the view, which is then passed
    // to the updateView method as the first argument. Because there is no
    // visualization, just return 'this'
    createView: function() {
        return this;
    },

    // Override this method to put the Splunk data into the view
    updateView: function(viz, data) {
        // Print the data object to the console
        console.log("The data object: ", data);

         var tokens = mvc.Components.get("default");

// Retrieve the value of a token $mytoken$
var tokenValue = tokens.get("token1");

console.log("Aready existsS" + tokenValue);
// Change the value of a token $mytoken$
tokens.set("token1", "this is the new value");

        //var tokens = mvc.Components.getInstance("default");
        //tokens.set("token1", "Test");
        console.log("Current --&amp;gt;" + tokens.get("token1"));
        var myResults = data[0];  // Sets this to the first (and only) row
        this.$el.html("The count of search results: &amp;lt;b&amp;gt;" + myResults + "&amp;lt;/b&amp;gt;");
    }
});

return DemoView;
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2016 10:32:21 GMT</pubDate>
    <dc:creator>rsathish47</dc:creator>
    <dc:date>2016-05-02T10:32:21Z</dc:date>
    <item>
      <title>How to set token value in the updateView using Javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-token-value-in-the-updateView-using-Javascript/m-p/227270#M14099</link>
      <description>&lt;P&gt;Hi all ,&lt;/P&gt;

&lt;P&gt;Can you please help me how to set token value in the updateView? I have added my code.&lt;/P&gt;

&lt;P&gt;I know that am missing something ,  please help me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;// demoview 
define(function(require, exports, module){
    // Base class for custom views
    var SimpleSplunkView = require('splunkjs/mvc/simplesplunkview');
    var mvc = require("splunkjs/mvc");

// Define the custom view class
var DemoView = SimpleSplunkView.extend({
    className: "demoview",

    // Change the value of the "data" property
    options: {
        data: "results"
    },

    // Override this method to configure your view
    // This function must return a handle to the view, which is then passed
    // to the updateView method as the first argument. Because there is no
    // visualization, just return 'this'
    createView: function() {
        return this;
    },

    // Override this method to put the Splunk data into the view
    updateView: function(viz, data) {
        // Print the data object to the console
        console.log("The data object: ", data);

         var tokens = mvc.Components.get("default");

// Retrieve the value of a token $mytoken$
var tokenValue = tokens.get("token1");

console.log("Aready existsS" + tokenValue);
// Change the value of a token $mytoken$
tokens.set("token1", "this is the new value");

        //var tokens = mvc.Components.getInstance("default");
        //tokens.set("token1", "Test");
        console.log("Current --&amp;gt;" + tokens.get("token1"));
        var myResults = data[0];  // Sets this to the first (and only) row
        this.$el.html("The count of search results: &amp;lt;b&amp;gt;" + myResults + "&amp;lt;/b&amp;gt;");
    }
});

return DemoView;
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 10:32:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-token-value-in-the-updateView-using-Javascript/m-p/227270#M14099</guid>
      <dc:creator>rsathish47</dc:creator>
      <dc:date>2016-05-02T10:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to set token value in the updateView using Javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-token-value-in-the-updateView-using-Javascript/m-p/227271#M14100</link>
      <description>&lt;P&gt;it is fixed by adding form.tokenname..&lt;/P&gt;

&lt;P&gt;tokens.set("form.token1", "this is the new value")&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 04:35:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-token-value-in-the-updateView-using-Javascript/m-p/227271#M14100</guid>
      <dc:creator>rsathish47</dc:creator>
      <dc:date>2016-05-04T04:35:09Z</dc:date>
    </item>
  </channel>
</rss>

