- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Help with multi-select input needed - save own variants
Hello,
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.
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.
Has anyone did anything similar?
Kind Regards,
Kamil
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


You can achieve by using cookie. Can you please try this?
<form script="a.js">
<label>MultiSelect with Cookie</label>
<fieldset submitButton="false">
<input type="multiselect" token="tkn_numbers" id="tkn_numbers_id">
<label>Numbers</label>
<fieldForLabel>a</fieldForLabel>
<fieldForValue>a</fieldForValue>
<search>
<query>|makeresults count=10 | eval a=1 | accum a</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
</input>
</fieldset>
</form>
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 < 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());
});
Thanks
KV
▄︻̷̿┻̿═━一 😉
If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
However I am not sure if I understand how this should work:
- 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.
Am I missing anything?
Kind Regards,
Kamil
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


