<?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 Help with multi-select input needed - save own variants in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571655#M46929</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I was wondering if this is feasible to have a multiselect input in the dashboars, which would allow to save down the chosen values as a user-variant and reuse it next time.&lt;/P&gt;&lt;P&gt;Example would be a list of SIDs (system IDs) in a monitoring dashboard, let us say around 20, which the user has to analyse. After choosing them in the first multiselect the user should get the possibility to save the selection under his own variant name, which would be offered next time he starts the dashboard.&lt;/P&gt;&lt;P&gt;Has anyone did anything similar?&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Kamil&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 13:10:49 GMT</pubDate>
    <dc:creator>damucka</dc:creator>
    <dc:date>2021-10-20T13:10:49Z</dc:date>
    <item>
      <title>Help with multi-select input needed - save own variants</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571655#M46929</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I was wondering if this is feasible to have a multiselect input in the dashboars, which would allow to save down the chosen values as a user-variant and reuse it next time.&lt;/P&gt;&lt;P&gt;Example would be a list of SIDs (system IDs) in a monitoring dashboard, let us say around 20, which the user has to analyse. After choosing them in the first multiselect the user should get the possibility to save the selection under his own variant name, which would be offered next time he starts the dashboard.&lt;/P&gt;&lt;P&gt;Has anyone did anything similar?&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Kamil&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 13:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571655#M46929</guid>
      <dc:creator>damucka</dc:creator>
      <dc:date>2021-10-20T13:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multi-select input needed - save own variants</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571693#M46930</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/138512"&gt;@damucka&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve by using cookie. &amp;nbsp;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="a.js"&amp;gt;
  &amp;lt;label&amp;gt;MultiSelect with Cookie&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="multiselect" token="tkn_numbers" id="tkn_numbers_id"&amp;gt;
      &amp;lt;label&amp;gt;Numbers&amp;lt;/label&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;a&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;a&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;|makeresults count=10 | eval a=1 | accum a&amp;lt;/query&amp;gt;
        &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc) {

    var submittedTokenModel = mvc.Components.get("submitted");
    var defaultTokenModel = mvc.Components.get('default');

    var current = Splunk.util.getConfigValue("USERNAME");

    function setsrcCookie(cookiename, cookievalue) {
        document.cookie = current + "_" + cookiename + "=" + cookievalue;
        console.log(document.cookie)
    }

    function getsrcCookie(cookiename) {
        var nameEQ = current + "_" + cookiename + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i &amp;lt; ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0)
                return c.substring(nameEQ.length, c.length);
        }
        return null;
    }
    submittedTokenModel.on("change:tkn_numbers", function() {
        var form_tkn_numbers = submittedTokenModel.get('form.tkn_numbers');
        setsrcCookie("tkn_numbers_cookie", form_tkn_numbers.join('| '));
    });

    var tkn_numbers_cookie = getsrcCookie("tkn_numbers_cookie");
    console.log("tkn_numbers_cookie", tkn_numbers_cookie.split("| "))
    defaultTokenModel.set("form.tkn_numbers", tkn_numbers_cookie.split("| "));
    submittedTokenModel.set(defaultTokenModel.toJSON());

});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一 &amp;nbsp; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 16:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571693#M46930</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-10-20T16:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multi-select input needed - save own variants</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571967#M46953</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;However I am not sure if I understand how this should work:&lt;/P&gt;&lt;P&gt;- With the code below I got a multiselect field with the 1 - 10 numbers to choose. I also copied the a.js to the ../etc/apps/MYAPP/appserver/static. But somehow I do not see the chosen values to be filled in again when I refresh / restart the form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I missing anything?&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Kamil&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 08:32:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/571967#M46953</guid>
      <dc:creator>damucka</dc:creator>
      <dc:date>2021-10-22T08:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with multi-select input needed - save own variants</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/572050#M46965</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/138512"&gt;@damucka&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can &amp;nbsp;you please share your sample code?&lt;/P&gt;&lt;P&gt;KV&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 16:46:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-with-multi-select-input-needed-save-own-variants/m-p/572050#M46965</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-10-22T16:46:15Z</dc:date>
    </item>
  </channel>
</rss>

