<?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: Sending User Defined Variables to Action Block in Splunk SOAR</title>
    <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747124#M1726</link>
    <description>&lt;P&gt;It seems that you are not using {0} in your query input.&lt;/P&gt;&lt;P&gt;Also can you post the sanitized code for the code block and the full entry for the data path of the 0 input?&lt;/P&gt;</description>
    <pubDate>Wed, 28 May 2025 14:32:52 GMT</pubDate>
    <dc:creator>marnall</dc:creator>
    <dc:date>2025-05-28T14:32:52Z</dc:date>
    <item>
      <title>Sending User Defined Variables to Action Block</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/746487#M1716</link>
      <description>&lt;P&gt;I am new to Splunk SOAR and I have a custom python code block that I am creating and exporting a variable to a Splunk action block.&lt;/P&gt;&lt;P&gt;The variable in the custom code block is set fine and with debug statements I can see it set correctly.&amp;nbsp; I then export that variable.&lt;/P&gt;&lt;P&gt;In the splunk action block , I import that variable but when I try to use it the value is set to "None".&amp;nbsp; When I import soar system variables, it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no error messages.&amp;nbsp; SOAR has the auto fill for the variables so not like I have a typo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screen shot below {0} is my customer code variable that gets set to none.&lt;/P&gt;&lt;P&gt;{1} is from the extract ip utility and that is set fine.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ma620k_0-1747670666264.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39045iF7D7BBFB45E79607/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ma620k_0-1747670666264.png" alt="ma620k_0-1747670666264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 16:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/746487#M1716</guid>
      <dc:creator>ma620k</dc:creator>
      <dc:date>2025-05-19T16:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sending User Defined Variables to Action Block</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747124#M1726</link>
      <description>&lt;P&gt;It seems that you are not using {0} in your query input.&lt;/P&gt;&lt;P&gt;Also can you post the sanitized code for the code block and the full entry for the data path of the 0 input?&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 14:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747124#M1726</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2025-05-28T14:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sending User Defined Variables to Action Block</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747168#M1727</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/310217"&gt;@ma620k&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Did you&amp;nbsp;&lt;SPAN&gt;defined as an output variable in the custom code block’s configuration?&lt;BR /&gt;&lt;BR /&gt;Your variable likely not being exported due to this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Reference -&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/SOARonprem/6.3.1/Playbook/CustomFunction" target="_blank"&gt;https://docs.splunk.com/Documentation/SOARonprem/6.3.1/Playbook/CustomFunction&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a kudos. Thanks!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 04:20:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747168#M1727</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-05-29T04:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sending User Defined Variables to Action Block</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747280#M1730</link>
      <description>&lt;P&gt;Thank you for the responses.&amp;nbsp; I copy/pasted some of the SOAR info below and as for the questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I did define the output variable in the custom code block config&lt;/LI&gt;&lt;LI&gt;I am not using {0} in the sample block because it kept giving an error .&amp;nbsp; I was using {1} because that was grabbing the IP through a utility and that was working for me.&lt;/LI&gt;&lt;LI&gt;The variable from the custom code block (extracted_ip_1) worked fine within the code block but was not set outside of it.&lt;/LI&gt;&lt;LI&gt;code_3:customer_function:extraced_ip_1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ma620k_0-1748628300202.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39244i0E9F02A407590163/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ma620k_0-1748628300202.png" alt="ma620k_0-1748628300202.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;def code_3(action=None, success=None, container=None, results=None, handle=None, filtered_artifacts=None, filtered_results=None, custom_function=None, loop_state_json=None, **kwargs):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; phantom.debug("code_3() called")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; regex_extract_ipv4_3__result = phantom.collect2(container=container, datapath=["regex_extract_ipv4_3:custom_function_result.data.extracted_ipv4","regex_extract_ipv4_3:custom_function_result.data.input_value"])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; container_artifact_data = phantom.collect2(container=container, datapath=["artifact:*.cef.cs1","artifact:*.cef.cs1Label"])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; regex_extract_ipv4_3_data_extracted_ipv4 = [item[0] for item in regex_extract_ipv4_3__result]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; regex_extract_ipv4_3_data_input_value = [item[1] for item in regex_extract_ipv4_3__result]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; container_artifact_cef_item_0 = [item[0] for item in container_artifact_data]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; container_artifact_cef_item_1 = [item[1] for item in container_artifact_data]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input_parameter_0 = ""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; code_3__extracted_ip_1 = None&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ################################################################################&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Custom Code Start&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ################################################################################&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;# Write your custom code here...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; extracted_ip_1 = regex_extract_ipv4_3_data_extracted_ipv4[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;################################################################################&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Custom Code End&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ################################################################################&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; phantom.save_run_data(key="code_3:extracted_ip_1", value=json.dumps(code_3__extracted_ip_1))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run_query_4(container=container)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 18:06:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747280#M1730</guid>
      <dc:creator>ma620k</dc:creator>
      <dc:date>2025-05-30T18:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sending User Defined Variables to Action Block</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747311#M1731</link>
      <description>&lt;P&gt;Ah there's your problem. You assign the variable "&lt;STRONG&gt;extracted_ip_1&lt;/STRONG&gt;" which then works fine within the function, but in the following phantom.save_run_data function call, it does not actually dump the value of the "&lt;STRONG&gt;extracted_ip_1&lt;/STRONG&gt;" variable into the output, but rather the "&lt;STRONG&gt;code_3__extracted_ip_1&lt;/STRONG&gt;" variable, which is previously set to None.&lt;/P&gt;&lt;P&gt;You should change the phantom.save_run_data command to use the correct variable name in the value parameter:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;phantom.save_run_data(key="code_3:extracted_ip_1", value=json.dumps(extracted_ip_1))&lt;/LI-CODE&gt;&lt;P&gt;Or, if you want to constrain all custom code between the "custom code" comment blocks, you can change the variable name:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;code_3__extracted_ip_1 = regex_extract_ipv4_3_data_extracted_ipv4[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also you mentioned your data path on the input to the following block is "&lt;STRONG&gt;code_3:customer_function:extraced_ip_1&lt;/STRONG&gt;", which has "&lt;STRONG&gt;customer_function&lt;/STRONG&gt;" but it should have "&lt;STRONG&gt;custom_function&lt;/STRONG&gt;". Not sure if this is just a typo in your post but if it exists also in your SOAR instance then it can also cause problems.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jun 2025 18:36:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747311#M1731</guid>
      <dc:creator>marnall</dc:creator>
      <dc:date>2025-06-01T18:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sending User Defined Variables to Action Block</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747394#M1735</link>
      <description>&lt;P&gt;Ah that all makes sense.&amp;nbsp; Thanks so much for the help.&amp;nbsp; &amp;nbsp;Can't wait to try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yep, that did the trick.&amp;nbsp; Thank you so much!&amp;nbsp; And yeah "customer" was just a typo on my part.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 16:45:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Sending-User-Defined-Variables-to-Action-Block/m-p/747394#M1735</guid>
      <dc:creator>ma620k</dc:creator>
      <dc:date>2025-06-09T16:45:14Z</dc:date>
    </item>
  </channel>
</rss>

