<?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 Re: Tokens Usage in Javascript Code in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Tokens-Usage-in-Javascript-Code/m-p/670208#M54844</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/262843"&gt;@dm2001&lt;/a&gt;&amp;nbsp;, it's been a long since I used tokens on JavaScript but when I used them I usually had these methods:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var defaultTokenModel = mvc.Components.getInstance('default', {
    create: true
});
var submittedTokenModel = mvc.Components.getInstance('submitted', {
    create: true
});

function setToken(name, value) {
    defaultTokenModel.set(name, value);
    submittedTokenModel.set(name, value);
};
function unsetToken(name) {
    defaultTokenModel.unset(name);
    submittedTokenModel.unset(name);
};
&lt;/LI-CODE&gt;&lt;P&gt;Then in your JS you can use the methods freely to set any token to a value or unset them.&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 15:11:16 GMT</pubDate>
    <dc:creator>garenilla</dc:creator>
    <dc:date>2023-11-29T15:11:16Z</dc:date>
    <item>
      <title>Tokens Usage in Javascript Code</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Tokens-Usage-in-Javascript-Code/m-p/669997#M54830</link>
      <description>&lt;P&gt;Hi, may I know any documentation on how tokens work when using them in javascript files. The docs at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.2/Viz/tokens" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.2/Viz/tokens&lt;/A&gt;&amp;nbsp;don't present much info on Javascript usage.&lt;/P&gt;&lt;P&gt;Particularly, I am trying to use tokens to delete KV store values and I am confused how this can be done. Just using tokens.unset() is not working.&lt;/P&gt;&lt;P&gt;Any help would be appreciated!!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 10:41:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Tokens-Usage-in-Javascript-Code/m-p/669997#M54830</guid>
      <dc:creator>dm2001</dc:creator>
      <dc:date>2023-11-28T10:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Tokens Usage in Javascript Code</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Tokens-Usage-in-Javascript-Code/m-p/670208#M54844</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/262843"&gt;@dm2001&lt;/a&gt;&amp;nbsp;, it's been a long since I used tokens on JavaScript but when I used them I usually had these methods:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var defaultTokenModel = mvc.Components.getInstance('default', {
    create: true
});
var submittedTokenModel = mvc.Components.getInstance('submitted', {
    create: true
});

function setToken(name, value) {
    defaultTokenModel.set(name, value);
    submittedTokenModel.set(name, value);
};
function unsetToken(name) {
    defaultTokenModel.unset(name);
    submittedTokenModel.unset(name);
};
&lt;/LI-CODE&gt;&lt;P&gt;Then in your JS you can use the methods freely to set any token to a value or unset them.&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 15:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Tokens-Usage-in-Javascript-Code/m-p/670208#M54844</guid>
      <dc:creator>garenilla</dc:creator>
      <dc:date>2023-11-29T15:11:16Z</dc:date>
    </item>
  </channel>
</rss>

