<?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 Re: How do I try an action several times? in Splunk SOAR</title>
    <link>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616926#M980</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249803"&gt;@ben_r&lt;/a&gt;&amp;nbsp;loops are not supported, yet, in playbooks but I would expect is on a roadmap somewhere as the community has been asking for a while! There is also no "retry n times on failure", but this could be written in to the app but you would need to let the app know how to determine the invalid response.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It depends on how you are determining a "valid response" but if you only need to try a max of 3 times, for now, and to keep your playbook "clean" from too much custom code, I would just have the action, followed by a decision 3 times. If the 1st action is "invalid response"&amp;nbsp; in the decision block, call the 2nd action block and so on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Loops can be done but you need to edit a lot of the code to make it work and it's not really best practise to do it like that.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 08:17:36 GMT</pubDate>
    <dc:creator>phanTom</dc:creator>
    <dc:date>2022-10-13T08:17:36Z</dc:date>
    <item>
      <title>How do I try an action several times?</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616852#M978</link>
      <description>&lt;P&gt;I have an action that I need a response from before the playbook can proceed, but the app is prone to occasionally time out or return an invalid result. To handle this, I want to try the action 3 times; if I still don't get a valid response, then the playbook should proceed with handling it as a failure and alert as such. I'm having trouble finding a good way to build the loop, though. It doesn't appear that there's a way to declare a variable (i.e. the loop counter) outside the action block, so I have no way to tell where I am in the loop. How can I declare a variable with global scope (or at least scope it outside the action block) in&amp;nbsp;&lt;SPAN&gt;5.2.1.78411? Alternately, is there a "retry this action&amp;nbsp;&lt;EM&gt;n&lt;/EM&gt; times if it fails" option that I can apply?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 17:58:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616852#M978</guid>
      <dc:creator>ben_r</dc:creator>
      <dc:date>2022-10-12T17:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I try an action several times?</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616926#M980</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249803"&gt;@ben_r&lt;/a&gt;&amp;nbsp;loops are not supported, yet, in playbooks but I would expect is on a roadmap somewhere as the community has been asking for a while! There is also no "retry n times on failure", but this could be written in to the app but you would need to let the app know how to determine the invalid response.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It depends on how you are determining a "valid response" but if you only need to try a max of 3 times, for now, and to keep your playbook "clean" from too much custom code, I would just have the action, followed by a decision 3 times. If the 1st action is "invalid response"&amp;nbsp; in the decision block, call the 2nd action block and so on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Loops can be done but you need to edit a lot of the code to make it work and it's not really best practise to do it like that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 08:17:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616926#M980</guid>
      <dc:creator>phanTom</dc:creator>
      <dc:date>2022-10-13T08:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I try an action several times?</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616983#M982</link>
      <description>&lt;P&gt;Thank you for the reply &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222170"&gt;@phanTom&lt;/a&gt;&amp;nbsp;; I was hoping there might be a canned action for it but I guess there isn't. I did try declaring a counter variable in global scope in a custom code block at the top of the playbook and tried testing against it in a decision block right after the action, but while I can address it in the custom blocks with global, there doesn't seem to be a way to make it available to the decision block:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;Oct 13, 09:06:20 : &lt;/SPAN&gt;&lt;SPAN class=""&gt;phantom.condition(): condition loop: condition 1, 'failed' '!=' 'success' =&amp;gt; result:True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;Oct 13, 09:06:20 : &lt;/SPAN&gt;&lt;SPAN class=""&gt;phantom.condition(): condition 2 to evaluate: LHS: global userDevicesLoop OPERATOR: &amp;lt; RHS: 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;Oct 13, 09:06:20 : &lt;/SPAN&gt;&lt;SPAN class=""&gt;phantom.condition(): condition loop: condition 2, 'userDevicesLoop' '&amp;lt;' '3.0' =&amp;gt; result:False&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;EM&gt;&lt;SPAN class=""&gt;(it's still 0 at that point, verified with a phantom.debug(str(userDevicesLoop)) in a section above that)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;For only three tries, I guess I can just stack actions and decisions like you suggested. It'll look cluttered and be awkward to build, but I'm not seeing a good alternative either, if there's no way to declare a value that can be addressed through the whole playbook.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Oct 2022 13:15:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/How-do-I-try-an-action-several-times/m-p/616983#M982</guid>
      <dc:creator>ben_r</dc:creator>
      <dc:date>2022-10-13T13:15:48Z</dc:date>
    </item>
  </channel>
</rss>

