Dashboards & Visualizations

passing dropdown value as a macro with argument

nivethainspire_
Explorer

I created a dashboard with 5 dropdowns
I passed values of 4 dropdowns in the 5th.. the macro given in is working fine , but the macro given as value="" is not expanding.. can anyone help me with this
Here is my code..

<form>
<fieldset submitButton="false">
<input type="radio" token="val1" searchWhenChanged="true"></input>
<input type="radio" token="val2" searchWhenChanged="true"></input>
<input type="radio" token="val3" searchWhenChanged="true"></input>
<input type="radio" token="val4" searchWhenChanged="true"></input>
<input type="radio" token="val4" searchWhenChanged="true">
      <choice value="`macro1($val1$,$val2$,$val3$,$val4$)`">yes</choice> //not working
      <choice value="`macro2($val1$,$val2$,$val3$,$val4$)`">no</choice> //not working
       <default>`macro2($val1$,$val2$,$val3$,$val4$)`</default> //working
    </input>
       </fieldset>
       <row> 
      <table>
        <search>
          <query>$type$ ...</query></search></table></row>
</form>
Tags (3)
0 Karma

niketn
Legend

While your question seems to have truncated, macro will be accepting strings as argument, hence you should try to change to the following:

`macro1("$val1$","$val2$","$val3$","$val4$")`

`macro2("$val1$","$val2$","$val3$","$val4$")`

Please try out putting the tokens under double quotes when you pass to macro and it should work. Let us know if it does not.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

nivethainspire_
Explorer

Tried!!!... not working

0 Karma

niketn
Legend

Change the value for val4 radio to yes and no, based on corresponding selected choice.
Then code the change event to set the macro token callMacro which can be used in your search query. In your case value for choice is considering token as string hence not replacing its actual token value. Please try out the following code and let us know. (PS two of your inputs were val4. I have converted one to val5).

<fieldset submitButton="false">
    <input type="radio" token="val1" searchWhenChanged="true"></input>
    <input type="radio" token="val2" searchWhenChanged="true"></input>
    <input type="radio" token="val3" searchWhenChanged="true"></input>
    <input type="radio" token="val4" searchWhenChanged="true"></input>
    <input type="radio" token="val5" searchWhenChanged="true">
       <choice value="yes">yes</choice> //not working
       <choice value="no">no</choice> //not working
        <default>no</default> //working
        <change>
              <condition value="yes">
                  <set token="callMacro">`macro1("$val1$","$val2$","$val3$","$val4$")`</set>
              </condition>
              <!-- Else or default condition, will be hit when choice is No-->
              <condition>
                  <set token="callMacro">`macro2("$val1$","$val2$","$val3$","$val4$")`</set>
              </condition>
        </change>
     </input>
</fieldset>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

nivethainspire_
Explorer

I get the output,but not the expected result

0 Karma

niketn
Legend

@niventhainspire_07, You have used just the code for val5 right?
I would say that the code should work, if there is an issue with macro you would need to fix yourself or provide the details of macro here.

If you want to test whether the tokens for val1...val4 are being set up properly, you can use the following

     <change>
           <set token="callMacro">val1:$val1$, val2:$val2$, val3:$val3$, val4:$val4$</set>
     </change>
   </input>
</fieldset>
<row>
    <panel>
        <title>$callMacro$</title>
    </panel>
</row>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...