This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
TL;DR: DotNet Tools Examples use SetFromString(), but Blob types do not work with this approach - Is there a way to copy or clone a record that I am missing?
I've written about 5 or 6 C# DotNet plug in tools, and they work nicely with limitations. The tools all take records in, do something, and add some fields to the records.
Currently, to pass the records through the tool, I do the following, once, in II_Init()...
- Create a new RecordInfo object called recordInfoOut. - Iterate over recordInfoIn, get each FieldBase, and call recordInfoOut.AddField() using each inbound FieldBase. - Call recordInfoOut.AddField() to add any extra fields I am going to add to each record.
This creates the format for the output record.
As the tool processes each individual record, I copy the data from the inbound record to the outbound record, extracting the string from the FieldBase using GetAsString() and using SetFromString() to set the new FieldBase, in II_PushRecord(). The examples in the C# SDK documentation use this method.
That works fine for simple field types that translate easily to string.
The problem is that when there are FieldTypes like Blob, there is no string representation, and I get an SEH unhandled exception when I try to use String type to copy.
Currently I work around this by not including Blobs in the inbound data stream. However, I am thinking that I might be doing something wrong in using string as an intermediary data type, and really there should be some record level Copy or Clone method around that allows me to copy inbound FieldBases to outbound FieldBases without changing type.
I have found the RecordCopier class and the member Copy, but I have no example code of how it should be used, and when I try to use it, Alteryx crashes out on me. I must be using it incorrectly.
Does anyone have any example implementations of NetPlugIn classes that can pass all FieldTypes through? I'm not asking to be spoonfed, but if you can give me any direction, I would really appreciate it.