<?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 Java SearchManager condition execution of function in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Java-SearchManager-condition-execution-of-function/m-p/549122#M9833</link>
    <description>&lt;P&gt;I am working with JavaSDK to execute custom python script.&amp;nbsp; In below code, i want to execute errorfunc (highlighted) in case "myResults.on("data", function ()" even is not triggered. How i can put non event condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;'underscore',&lt;BR /&gt;'jquery',&lt;BR /&gt;'splunkjs/mvc',&lt;BR /&gt;"splunkjs/mvc/searchmanager",&lt;BR /&gt;'splunkjs/mvc/simplexml/ready!'&lt;BR /&gt;], function (_, $, mvc, SearchManager) {&lt;BR /&gt;console.log("sample.js has been loaded");&lt;BR /&gt;buttonClick()&lt;/P&gt;&lt;P&gt;function buttonClick(){&lt;BR /&gt;$("#run_search_btn").on("click",function(){&lt;BR /&gt;console.log("Clicked")&lt;BR /&gt;$('#run_search_btn').attr( "disabled", "disabled" );&lt;/P&gt;&lt;P&gt;script1 = "| script XPDM_Creation"&lt;/P&gt;&lt;P&gt;function success(val_cnt,val){&lt;BR /&gt;console.log("Search Result: Successful");&lt;BR /&gt;console.log("Result:",val_cnt);&lt;BR /&gt;console.log(val);&lt;BR /&gt;alert("Generated");&lt;BR /&gt;$("#run_search_btn").removeAttr( "disabled");&lt;BR /&gt;}&lt;BR /&gt;function err(){&lt;BR /&gt;console.log("Search Result: Failed");&lt;BR /&gt;alert("Generation Failed")&lt;BR /&gt;$("#run_search_btn").removeAttr( "disabled");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;runScript1(script1,success,err)&lt;/P&gt;&lt;P&gt;})&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;function runScript1(script1, successfunc, errorfunc) {&lt;BR /&gt;var result = [];&lt;BR /&gt;var lookupSearch = new SearchManager({&lt;BR /&gt;earliest_time: "-24h@h",&lt;BR /&gt;latest_time: "now",&lt;BR /&gt;search: script1&lt;BR /&gt;});&lt;BR /&gt;var myResults = lookupSearch.data("results");&lt;BR /&gt;&lt;BR /&gt;lookupSearch.on("search:done", function () {&lt;BR /&gt;console.log(myResults)&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;myResults.on("data", function ()&lt;/FONT&gt; {&lt;BR /&gt;result_cnt = myResults.data().rows;&lt;BR /&gt;myResults_text = myResults.data().rows[0][0];&lt;BR /&gt;successfunc(result_cnt,myResults_text)&lt;BR /&gt;})&lt;BR /&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;errorfunc()&lt;/FONT&gt;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;lookupSearch.on('search:failed', function(properties) {&lt;BR /&gt;// Print the entire properties object&lt;BR /&gt;console.log("FAILED:", properties);&lt;BR /&gt;errorfunc()&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;lookupSearch.on('search:error', function(properties) {&lt;BR /&gt;// Print the entire properties object&lt;BR /&gt;console.log("FAILED:", properties);&lt;BR /&gt;errorfunc()&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;lookupSearch.on('search:progress', function(properties) {&lt;BR /&gt;// Print just the event count from the search job&lt;BR /&gt;console.log("IN PROGRESS.\nEvents so far:", properties.content.eventCount);&lt;BR /&gt;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;BR /&gt;})&lt;/P&gt;</description>
    <pubDate>Fri, 23 Apr 2021 13:11:56 GMT</pubDate>
    <dc:creator>yogip86</dc:creator>
    <dc:date>2021-04-23T13:11:56Z</dc:date>
    <item>
      <title>Java SearchManager condition execution of function</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Java-SearchManager-condition-execution-of-function/m-p/549122#M9833</link>
      <description>&lt;P&gt;I am working with JavaSDK to execute custom python script.&amp;nbsp; In below code, i want to execute errorfunc (highlighted) in case "myResults.on("data", function ()" even is not triggered. How i can put non event condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;'underscore',&lt;BR /&gt;'jquery',&lt;BR /&gt;'splunkjs/mvc',&lt;BR /&gt;"splunkjs/mvc/searchmanager",&lt;BR /&gt;'splunkjs/mvc/simplexml/ready!'&lt;BR /&gt;], function (_, $, mvc, SearchManager) {&lt;BR /&gt;console.log("sample.js has been loaded");&lt;BR /&gt;buttonClick()&lt;/P&gt;&lt;P&gt;function buttonClick(){&lt;BR /&gt;$("#run_search_btn").on("click",function(){&lt;BR /&gt;console.log("Clicked")&lt;BR /&gt;$('#run_search_btn').attr( "disabled", "disabled" );&lt;/P&gt;&lt;P&gt;script1 = "| script XPDM_Creation"&lt;/P&gt;&lt;P&gt;function success(val_cnt,val){&lt;BR /&gt;console.log("Search Result: Successful");&lt;BR /&gt;console.log("Result:",val_cnt);&lt;BR /&gt;console.log(val);&lt;BR /&gt;alert("Generated");&lt;BR /&gt;$("#run_search_btn").removeAttr( "disabled");&lt;BR /&gt;}&lt;BR /&gt;function err(){&lt;BR /&gt;console.log("Search Result: Failed");&lt;BR /&gt;alert("Generation Failed")&lt;BR /&gt;$("#run_search_btn").removeAttr( "disabled");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;runScript1(script1,success,err)&lt;/P&gt;&lt;P&gt;})&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;function runScript1(script1, successfunc, errorfunc) {&lt;BR /&gt;var result = [];&lt;BR /&gt;var lookupSearch = new SearchManager({&lt;BR /&gt;earliest_time: "-24h@h",&lt;BR /&gt;latest_time: "now",&lt;BR /&gt;search: script1&lt;BR /&gt;});&lt;BR /&gt;var myResults = lookupSearch.data("results");&lt;BR /&gt;&lt;BR /&gt;lookupSearch.on("search:done", function () {&lt;BR /&gt;console.log(myResults)&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;myResults.on("data", function ()&lt;/FONT&gt; {&lt;BR /&gt;result_cnt = myResults.data().rows;&lt;BR /&gt;myResults_text = myResults.data().rows[0][0];&lt;BR /&gt;successfunc(result_cnt,myResults_text)&lt;BR /&gt;})&lt;BR /&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;errorfunc()&lt;/FONT&gt;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;lookupSearch.on('search:failed', function(properties) {&lt;BR /&gt;// Print the entire properties object&lt;BR /&gt;console.log("FAILED:", properties);&lt;BR /&gt;errorfunc()&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;lookupSearch.on('search:error', function(properties) {&lt;BR /&gt;// Print the entire properties object&lt;BR /&gt;console.log("FAILED:", properties);&lt;BR /&gt;errorfunc()&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;lookupSearch.on('search:progress', function(properties) {&lt;BR /&gt;// Print just the event count from the search job&lt;BR /&gt;console.log("IN PROGRESS.\nEvents so far:", properties.content.eventCount);&lt;BR /&gt;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;BR /&gt;})&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 13:11:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Java-SearchManager-condition-execution-of-function/m-p/549122#M9833</guid>
      <dc:creator>yogip86</dc:creator>
      <dc:date>2021-04-23T13:11:56Z</dc:date>
    </item>
  </channel>
</rss>

