<?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 How can I pre-define output fields in Dev Space</title>
    <link>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712891#M1411</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm building a custom tool with Python SDK and I'm having a problem when connecting it to other tools that have&amp;nbsp;&lt;SPAN&gt;FieldSelector field (for example Text to columns tool. Where you can select the Column to split by connecting its input with another tool's output, and you can select which field contains the data to split).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Right now I need to run the workflow for the first time in order to list out the output fields of my custom tool. But in a large workflow, this became annoying.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where can I define the output fields for my custom tool? Is it in the XML file or inside the python file?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I saw there's a function named&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;pi_add_outgoing_connection,&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;is that where I can use it to define the output fields?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2021 12:19:02 GMT</pubDate>
    <dc:creator>giang_hoang7667</dc:creator>
    <dc:date>2021-02-03T12:19:02Z</dc:date>
    <item>
      <title>How can I pre-define output fields</title>
      <link>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712891#M1411</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm building a custom tool with Python SDK and I'm having a problem when connecting it to other tools that have&amp;nbsp;&lt;SPAN&gt;FieldSelector field (for example Text to columns tool. Where you can select the Column to split by connecting its input with another tool's output, and you can select which field contains the data to split).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Right now I need to run the workflow for the first time in order to list out the output fields of my custom tool. But in a large workflow, this became annoying.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where can I define the output fields for my custom tool? Is it in the XML file or inside the python file?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I saw there's a function named&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;pi_add_outgoing_connection,&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;is that where I can use it to define the output fields?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 12:19:02 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712891#M1411</guid>
      <dc:creator>giang_hoang7667</dc:creator>
      <dc:date>2021-02-03T12:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I pre-define output fields</title>
      <link>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712901#M1412</link>
      <description>&lt;P&gt;Are you initializing your output anchor?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.alteryx.com/developer/current/Python/use/OutputAnchorClass.htm?tocpath=SDKs%7CBuild%20Custom%20Tools%7CPython%20SDK%7CClasses%7COutputAnchor%7C_____0#init" target="_blank" rel="noopener"&gt;Link to docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The basic process looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. During your plugin's pi_init method, get the output anchor&lt;/P&gt;&lt;P&gt;2a. If your tool is an input tool, initialize the output in pi_push_all_records&lt;/P&gt;&lt;P&gt;2b. If your tool accepts incoming data, initialize the output during (one of) the incoming connection's ii_init methods&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An input tool might look something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class AyxPlugin:
    def __init__(self, n_tool_id: int, alteryx_engine: object, output_anchor_mgr: object):
        self.output_anchor_mgr: Sdk.OutputAnchorManager = output_anchor_mgr
        self.Output: Sdk.OutputAnchor = None

    def pi_init(self, str_xml: str):
        self.Output = self.output_anchor_mgr.get_output_anchor('Output')

    def pi_push_all_records(self, n_record_limit: int) -&amp;gt; bool:
        # Some code to generate your recordinfo
        self.Output.init(record_info)
        # Rest of code to push data to your output anchor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A tool that accepts incoming connections might look like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class AyxPlugin:
    def __init__(self, n_tool_id: int, alteryx_engine: object, output_anchor_mgr: object):
        self.output_anchor_mgr: Sdk.OutputAnchorManager = output_anchor_mgr
        self.Output: Sdk.OutputAnchor = None

    def pi_init(self, str_xml: str):
        self.Output = self.output_anchor_mgr.get_output_anchor('Output')

    def pi_add_incoming_connection(self, str_type: str, str_name: str) -&amp;gt; object:
        return IncomingInterface(self)


class IncomingInterface:
    def __init__(self, parent: AyxPlugin):
        self.parent = parent

    def ii_init(self, record_info_in: object) -&amp;gt; bool:
        # Some code to generate your outgoing recordinfo based on incoming fields
        self.parent.Output.init(record_info_out)
        # The rest of your init code&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, the init method causes the SDK to send a message to Alteryx that allows connected tools to receive a preview of the data structure you are sending.&amp;nbsp; This allows tools with FieldSelectors or Select tool functionality to fill in their interfaces with the incoming field info.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 12:41:12 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712901#M1412</guid>
      <dc:creator>tlarsen7572</dc:creator>
      <dc:date>2021-02-03T12:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I pre-define output fields</title>
      <link>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712934#M1413</link>
      <description>&lt;P&gt;Oh, I get it now. I was initing the output anchor after validating the tool is&amp;nbsp;UpdateOnly or not. That's why it needs to run 1 time before showing the output fields.&lt;/P&gt;&lt;P&gt;Thank you&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Fireball lia-component-message-view-widget-author-username"&gt;&lt;A href="https://community.alteryx.com/t5/user/viewprofilepage/user-id/21782" target="_self"&gt;&lt;SPAN class="login-bold"&gt;tlarsen7572&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 13:36:50 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/How-can-I-pre-define-output-fields/m-p/712934#M1413</guid>
      <dc:creator>giang_hoang7667</dc:creator>
      <dc:date>2021-02-03T13:36:50Z</dc:date>
    </item>
  </channel>
</rss>

