How to Exclude "Notes" from ODK Form Submissions?

Hello ODK Community,

I am designing an ODK form using XLSForm, and I have several note fields included for surveyor guidance. These notes are meant to be visible only during data collection but should not appear in the final CSV submission.

I am looking for a reliable way to ensure that these note fields are either:

Not included in the submission data (i.e., excluded from the CSV).
Hidden from the form in a way that they do not interfere with the final data export.
What is the best approach to achieve this? Should I use the relevant column with a condition, mark them with an appearance, or is there another method to prevent these note fields from being exported with the data?

Any help or examples would be greatly appreciated!

Thanks in advance for your guidance!

1 Like

Hi! If I am correct, then ODK Central doesn't facilitate downloading the data (.CSVs) for selective columns as of now. But, I know a helpful trick which can help you achieve the same!

Load the data to power query in excel using OData feed. Add steps to remove the "Notes" fields in power query. And, we're done! Everytime you refresh this document, the power query will automatically fetch the updated data from the ODK Central server and will also remove all of the notes fields from it by itself. Then, it can be saved as Excel or CSV, however convenient!

2 Likes

Thanks. I will try with API, I hope to get this feature in ODK in future.

It probably helps to understand what in fact an XLSForm note really is:

  • a note is just a (permanently) read-only text question

This is perhaps best illustrated with a simple example: this is a basic XLSForm form with a text question and a note:

Note.xlsx (14.2 KB)

This becomes the following XForm form definition, which is the thing that is actually consumed by and rendered by the client (Collect or Enketo):

<?xml version="1.0"?>
<h:html
    xmlns="http://www.w3.org/2002/xforms"
    xmlns:h="http://www.w3.org/1999/xhtml"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jr="http://openrosa.org/javarosa"
    xmlns:orx="http://openrosa.org/xforms"
    xmlns:odk="http://www.opendatakit.org/xforms">
    <h:head>
        <h:title>Note</h:title>
        <model odk:xforms-version="1.0.0">
            <instance>
                <data id="Note" version="1">
                    <A/>
                    <B/>
                    <meta>
                        <instanceID/>
                    </meta>
                </data>
            </instance>
            <bind nodeset="/data/A" type="string"/>
            <bind nodeset="/data/B" readonly="true()" type="string"/>
            <bind nodeset="/data/meta/instanceID" type="string" readonly="true()" jr:preload="uid"/>
        </model>
    </h:head>
    <h:body>
        <input ref="/data/A">
            <label>This is a regular text question</label>
        </input>
        <input ref="/data/B">
            <label>This is a note</label>
        </input>
    </h:body>
</h:html>

Note.xml (1.2 KB)

As you can see, the only difference between A and B is that B is readonly=true. When you complete your form and submit, all the <instance>...</instance> data payload is sent up to the server (eg Central); there is no way to exclude any of it. Yes, you can use the relevance column, but this only blanks the individual data XML element value upon submission; it doesn't actually remove that XML element entirely from the payload (hence the 'note' B always gets submitted too, with an empty value)

Basically, when rendering the above XForm form definition, the client (Collect or Enketo) happens to notice that the control has a permanent readonly=true, and therefore knows to display its label just as a simple note, instead of a showing regular text question with an input box.

So the only reliable way to remove 'notes' is to identify them in the form definition as readonly text questions, and filter these elements out accordingly; there is nothing in the actual submission payload itself that indicates what is or is not a 'note'. It is also not sufficient to filter out all empty fields, since some of these may or may not be notes (eg it could just be the optional text question A that the user didnt bother to answer).

Hope that helps.

1 Like