Uploading a Data File

WorkMobile has the concept of a DataLinkDrop down file which is intended to allow a form designer to provide a way for their users of drilling down into narrower categories until a value can be selected for the form or be used to drive other formulas in the form.

You can familiarise yourself of this functionality by using the WorkMobile web portal to design a form with a simple DLD.

If we take a very simple nested dataset of cars - the first DLD (dropdown list) could be used to select the manufacturer - a following DLD could allow the user to select the model from a list filtered by manufacturer. A third list would allow the user to display the colours available for that model.

In our case selecting Ford and Fiesta would provide the 3rd list with the values Black and Red
Selecting Fiat & Punto would provide a list of Black and Green

  1. Ford
    1. Fiesta
      1. Black
      2. Red
    2. Focus
      1. Red
  2. Fiat
    1. Punto
      1. Black
      2. Green

We can express this in a simpe CSV file or as an XML document

As CSV:

Manufacturer,Model,Colour
Ford,Fiesta,Black
Ford,Fiesta,Red
Ford,Focus,Red
Fiat,Punto,Black
Fiat,Punto,Green
 

As XML:

<?xml version="1.0" encoding="UTF-8"?>
<data name="Cars">
   <node name="Manufacturer" value="Ford">
      <node name="Model" value="Fiesta">
          <node name="Colour" value="Black" />
          <node name="Colour" value="Red" /> 
      </node>
      <node name="Model" value="Focus">
          <node name="Colour" value="Red" />
      </node>
   </node>
   <node name="Manufacturer" value="Fiat">
       <node name="Model" value="Punto">
         <node name="Colour" value="Black" />
         <node name="Colour" value="Green" />
      </node>
   </node>
</data>

The developer has the option of supplying either of these formats simply by setting the Data property. It isn't necessary to specify the type of data being uploaded (CSV or XML) as this is inferred by the data supplied

C#

// create object
BODataLinkData dataFile = new BODataLinkData();
// "dataToUpload" is a string, containing the entire text to upload, XML or CSV
dataFile.Data = dataToUpload;
// "name" is the same field as the unique data file name on the website 
dataFile.Name = "Parts";
// must set this to true to overwrite existing data 
dataFile.Overwrite = true;
// same as adding other types
int dataFileId = service.Add(dataFile, credentials);

Java

// create object
BODataLinkData dataFile = new BODataLinkData();
// "dataToUpload" is a string, containing the entire text to upload, XML or CSV
dataFile.setData(dataToUpload);
// "name" is the same field as the unique data file name on the website
dataFile.setName("Parts");
// must set this to true to overwrite existing data 
dataFile.setOverwrite(true);
// same as adding other types
int dataFileId = service.add(dataFile, credentials);

To overwrite existing data, use the same Name as the original upload, and set Overwrite to true. The structure of the data must remain the same (same number of columns, with the same column headings for CSV, or the same depth with the same node names for XML). Any forms using that data file will be automatically updated. Phones will automatically receive the updated file next time the send/receive.