Hi Guys,
I'm developing a Plug-In to read data from CSV file to a CDT. There is any way to return a generic CDT (without type)?
Discussion posts and replies are publicly visible
According to the Appian Public API's, and the Custom Smart Service documentation, it is not supported to return the 'Object' type directly from a plugin.
Have you considered the "Excel Tools" shared component?
If Excel Tools does not work for you, my recommendation is to create a separate Appian-callable custom function in Java, one per CDT you need to ingest and pass arrays of the CDT's (not the XML) between Appian and Java. While there's a bit of copy/paste boilerplate code, it would significantly reduce the complexity of your overall need and be more efficient in the longer-term.
If you still really think "generic" is the best way to go...
It is possible to meet your specific description in a less-generic way, but please read the caveats later. You would want to use Java's XJC compiler to create a POJO with JAXB annotations that mirror the CDT's you expect to use in Appian. Then, your plugin would have to know the type that each CSV line represents (presumably as an input). Based upon the expected type and CSV read-in, you would class-load and fill in multiple POJO's in Java. In Java you would then marshal the XML, return the string array of XML and do an apply(torecord(), ... ) on the result in Appian.
There are some major caveats to attempting a generic approach like this, however.
Guide to generating POJO's from XSD's using XJC: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/xjc.html
XML Marshalling: Google jaxb marshal pojo to xml