ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now

Dev Space

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

Using V_String as Field type for Output RecordInfo in Custom Tool using Python SDK

fardeen9983
8 - Asteroid

I am creating a custom download tool using the Python SDK. The output will include lengthy 30k+ lines of JSON string response. The documentation for the class Field denotes "string" to be used for all possible string data types in Alteryx. But add_field or add_field_from_xml method for RecordInfo is also asking for a fixed size, in absence of which, the following error is thrown:

 

Code used

 

self.rio = Sdk.RecordInfo(1)

# using Add Field From XML
self.rio.add_field_from_xml("<Field name=\"DownloadHeders\" type=\"V_String\" >")
self.rio.add_field_from_xml("<Field name=\"DownloadData\" type=\"V_String\" >")

# Using Add Field
self.rio.add_field("DownloadHeaders", Sdk.FieldType.string)
self.rio.add_field("DownloadData", Sdk.FieldType.string)

 

 

Error Thrown

Downloadheaders.png

 

 

 

 

 

 

 

In the scenario where I do specify the size and it exceeds the limit, following warning and error is thrown

Browse.png

So my question is how do I use v_string i n the python code without having to specify a fixed size for the field?

tlarsen7572
11 - Bolide

Hi @fardeen9983 , use Sdk.FieldType.v_string to add a V_String field.  You will need to specify the max number of characters that field can hold, which I tend to default to the max possible of 2147483647.  The actual size of the field will vary with the size of the data being stored.  The function call would look something like this:

 

self.rio.add_field("DownloadData", Sdk.FieldType.v_string, size=2147483647)