Free Trial

Dev Space

Customize and extend the power of Alteryx with SDKs, APIs, custom tools, and more.
SOLVED

Creating a tool with SDK

dougperez
12 - Quasar

Hello Guys!

 

I'm new into develop tools with the SDK, I was studying that with this link: https://www.youtube.com/watch?v=_TZfIbWnyoQ

I watched it all, so I wanted to create one by myself, using this API (It's a simple API, I know that I can just create a macro, but I want to create this with the SDK): https://api.nasa.gov/ 

I followed all the tutorial, read the documentation and tried to do the file attached, but I don't execute, I don't know why, can someone help me with this ? 

 

Regards

3 REPLIES 3
tlarsen7572
11 - Bolide
11 - Bolide

Hey @dougperez, great to see another SDK user! I am the guy who @Nick612Haylund interviewed in that video you posted.

 

In short, I was able to get your tool working:

Screen Shot 2022-01-20 at 7.55.13 PM.png

 

 

Here are the things I had to change:

  • You have coded your tool as a pass-through tool, but you have configured it as an input tool because you did not provide any input connection. In NasaConfig.xml, I changed the GuiSettings tag to look like this:
<GuiSettings Html="Nasa.html" Icon="nasa.png" Help="" SDKVersion="10.1">

  <InputConnections>

    <Connection Name="Input" AllowMultiple="False" Optional="False" Type="Connection" Label=""/>

  </InputConnections>

  <OutputConnections>

    <Connection Name="Output" AllowMultiple="False" Optional="False" Type="Connection" Label=""/>

  </OutputConnections>

</GuiSettings>

  • In line 69 of Nasa.py, I had to fix the definition of the 'json' field. 'str' is not a valid field type. I used v_string with a size of 100000:
self.resultJson = self.OutInfo.add_field('json', Sdk.FieldType.v_string, size=100000, source=self.parent.label)
  • In line 84 I changed the way the at variable is calculated. I just assumed a string input field, so no need to do the date time conversions. This is kind of lazy, so your way is probably better. I couldn't get the date-time formatting to work quickly, so I went with something simple just to get the tool working:
at = self.DateField.get_as_string(in_record)
  • Finally, in line 90 I had to make sure I was setting the json field from the 'text' property of the response, not the response itself:
self.resultJson.set_from_string(self.Creator, response.text)

 

The first bullet point about the config file was the most critical; the rest are simple syntax errors. If you want to create a pass-through tool (which uses the IncomingInterface class) then you need to define at least 1 incoming connection. If you want to create an input tool (which has 0 incoming connections), then all of the record processing has to happen in pi_push_all_records.

 

Hope this helps!

dougperez
12 - Quasar

Hello @tlarsen7572, good to see the stars coming to help me (just joking hahahaha) 

So, I found out how to create a Input tool , thanks to show me how to create a pass-through tool.

I have other question, do you guys have another video showing the new platform SDK? I was told that the old don't have alteryx support anymore...

tlarsen7572
11 - Bolide
11 - Bolide

Always happy to help someone interested in the SDKs!

 

Short answer to your question: no.

 

Long answer:

The docs do a good job of introducing the new SDKs (https://help.alteryx.com/developer-help/platform-sdk). I'd start there and ask questions in the Community. I have played with the new SDK a bit, but am not too familiar with it. It's not because there is anything wrong with the new SDK. I actually quite like the new APIs. It's mainly because I created my own SDK for the Go programming language (I modelled the design after the platform SDK). I much prefer coding with Go rather than Python, so most of my custom tools now are Go-built tools.