2
1
0

We have a few clients who require a csv/xls output of their submission data. We are finding the data extracts unreliable for this, especially if the report needs to span several versions and the form contains repeats.

We would like to write a custom service to query the xml for a particular form and return the values for specified xpaths to a csv file.

Are there any articles that could give us some pointers on how to start?

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Lin,

      some of our reference data comes from our back end systems as xml.

      So, I use

      Path path= new Path(xml)

      and then use

      path.paths("//XPath expression").collect { item -> transform }.join(",")

      It works well because the data is structured as a collection of a single defined object.

      It may be more challenging to get formXml → csv, but if you use Path, then write a map (instead of a simple collect) and use XPath expressions, you could end up with a csv output of the form fields as a list of key, value pairs.

      I have some other cases where I convert xml to a Map<String, String>. The map is easy to work with rather than try to mangle the xml directly.

      Hope that is some food for thought.


      Thanks

      Mark

      1. Sindy Tang

        Hi Mark,

        Thanks for the answer!  What service type will you use in TM when you need to get data like that?

        Regards

        Sindy

      2. Mark Murray

        Hi Sindy,

        the services are simple Groovy Service.

        The one to get data from our back end system uses http call to communicate with our back end.

        The service to transform the data has the code above to transform the xml to csv.

        So, service 2 calls service 1 to get data, then service 2 transforms the data to csv, then it updates an Organisation Property in TM, so the data is available to our forms.


        Hope that helps.

        Let me know if you need any more details.

        Thanks

        Mark

      3. Sindy Tang

        Hi Mark,

        I want to find a way to get submission xml by using Fluent API. Is it possible?

        You could refer to com.avoka.fc.core.dao.* to get access to the submssionsDataDao in the Core API. Is there anything similar to that in Fluent API you can use?

        Regards

        Sindy

      CommentAdd your comment...