Dashboards & Visualizations

Why is my multiselect dynamic delimiter with token not updating on token element change?

altink
Builder

Dear All,

I have put a token in place of a multi-select's delimiter in order to realize an AND/OR switch for the options.

     <input type="multiselect" token="field2">
      <label>Extra Options</label>
      <default>ALL</default>
      <choice value="*">ALL</choice>
      <choice value="SEO_SEC=1">Sec</choice>
      <choice value="SEO_ACC=1">Acc</choice>
      <choice value="SEO_ORA=1">Ora</choice>
      <delimiter> $field3$ </delimiter>

    </input>
    <input type="dropdown" token="field3" searchWhenChanged="true">
      <label>field3</label>
      <choice value="OR">Or</choice>
      <choice value="AND">And</choice>
      <default>OR</default>
     </input>
.......................................................
 index=* .... | search ...   ($field2$)

The problem I have is:
that only way to have the change of the dropdown field3 effective, is to change something in the multiselect field2!

How can I have the change of field3 set the right delimiter on field2 and run the search?

best regards
Altin

ps. Simple XML - best

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@altink

I have used javascript for this. Can you please try this?

<form script="conditional_multiselect.js">
  <label>Conditional Multiselect</label>
  <fieldset submitButton="false">
   <input type="multiselect" token="field2" id="field2_id" >
       <label>Extra Options</label>
       <default>ALL</default>
       <choice value="*">ALL</choice>
       <choice value="SEO_SEC=1">Sec</choice>
       <choice value="SEO_ACC=1">Acc</choice>
       <choice value="SEO_ORA=1">Ora</choice>
       <delimiter> $field3$ </delimiter>
     </input>
     <input type="dropdown" id="field3_id" token="field3" searchWhenChanged="true">
       <label>field3</label>
       <choice value="OR">Or</choice>
       <choice value="AND">And</choice>
       <default>OR</default>
      </input>
  </fieldset>
  <row>
    <panel>
      <html>
        $field2$
      </html>
    </panel>
  </row>
</form>

conditional_multiselect.js

require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function($, mvc) {
   var field3 = mvc.Components.get("field3_id");
  //  headerView.render();
  field3.on("change",function(){
    var field2 = mvc.Components.get("field2_id");
    field2.render();     
  })
  console.log("Hiwwwww",field3);
});

Thanks

0 Karma

altink
Builder

Dear @kamlesh_vaghela

thank you very much for your reply, but I forgot to mention, that I need it done by Simple XML only and no extra things. will update on body

thank you very much again.

best regards,
Altin

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...