Dashboards & Visualizations

Why do I have to reload my dashboard to execute a search?

JarrenJ
Explorer

I am using Javascript to dynamically add a hash string to an input from splunk, based on its ID. it updates the value of the input but when i click Submit, it doesnt do anything. I have to refresh the page and then paste in the value for it to work. This defeats the purpose of autofilling the input field based on the file uploaded.

any help would appreciated, thanks!

EDIT:

This is my script:

$(document).ready(function () {
  $("#btn").click(function () {
      var reader = new FileReader(); //define a Reader
      var file = $("#f1")[0].files[0]; //get the File object 
      if (!file) {
          alert("no file selected");
          return;
      } //check if user selected a file

      reader.onload = function (f) {
          var file_result = this.result; // this == reader, get the loaded file "result"
          var file_wordArr = CryptoJS.lib.WordArray.create(file_result); //convert blob to WordArray
          var sha1_hash = CryptoJS.SHA1(file_wordArr); //calculate SHA1 hash
            $('#input1_3520-input').attr('value', sha1_hash);
          //document.getElementById("input1_3520-input").value = sha1_hash; //put hash into input field
          //alert("Calculated SHA1:" + sha1_hash.toString()); //output result
      };
      reader.readAsArrayBuffer(file); //read file as ArrayBuffer
  });
});

It works, it puts the generated hash into my field but to actually run the search, I need to copy the hash, reload the page and then paste it in and it works... I don't think its a timing issue. Could it be that it is only changing the text value of the input field and not that actual value?

EDIT #2:

Now, I don't need to reload the page i just need to actually type a character in the field, hit submit, then delete the added character and hit submit again and it runs the search on the hash... My only guess is that the input field isn't actually detected a value change?

0 Karma

elliotproebstel
Champion

I've seen behavior like this when my javascript had some timing issues. Can you share the dashboard XML and javascript code? Feel free to obfuscate any sensitive data.

0 Karma

JarrenJ
Explorer

thanks for the response guys, see the updated question.

0 Karma
Get Updates on the Splunk Community!

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...

Cloud Platform & Enterprise: Classic Dashboard Export Feature Deprecation

As of Splunk Cloud Platform 9.3.2408 and Splunk Enterprise 9.4, classic dashboard export features are now ...