Retrieving Form Data

Several options exist for retrieving your form data through the API

Just like the CSV download page in the website, the API gives you the option to download all data, or only new data (those not marked as downloaded already). 

Also, there is the option to mark downloaded data as "downloaded", or not.

You can also retrieve data via a paging like function RetrieveNFormDataStartingAfterId this allows you to ask WorkMobile to supply a feed of records in a batch starting from a particular id. This avoids any of the communication failures that could leave simpler scenario in marking records that you haven't received and should form the basis of any critical integration work. The simpler download method is supplied for more ad-hoc scenarios.

An additional call of RetrieveNLatest will allow you to show a live feed of data coming into a form. 

Within your downloaded data, some form element names may be changed. If there were duplicate
names, some will have had a number appended, to make each one unique. Any "special" characters
will have been escaped in the form "_xhhhh_", where hhhh is the unicode value of the character. For
example, a space will become "_x0020_".

C#

BOUserForm form = new BOUserForm();
form.UserFormId = REQUIRED_FORM_ID;
form.UserId = credentials.CustomerId;
bool markAsDownloaded = false;
BOFormData data = service.RetrieveAllData(form, credentials, markAsDownloaded);
System.Data.DataSet dataset = data.FormDataTable;

Java

BOUserForm form = new BOUserForm();
form.setUserFormId(REQUIRED_FORM_ID);
form.setUserId(credentials.getCustomerId());
boolean markAsDownloaded = false;
BOFormData data = service.retrieveAllData(form, credentials, markAsDownloaded);
String xml = data.getXMLData();

In many mid range scenarios and data sizes these methods will work well, are efficient in terms of both performance, coding and solution complexity. 

To support heavier loads and larger datasets the RetrieveNFormDataStartingAfterId 
 method has been introduced for data retrieval. This doesnt rely on the mark as downloaded flag and therefore give more flexibility to retrieve data from a single form in batches, allow multiple consumers of that data and give a more robust approach to re-requesting data that may have failed to be received or stored properly at the consumer. 

It is the responsibility of the client to keep track of the last id received per form and then use that id to request the next batch of data
 

C#

BOFormData objFormData = null;
    
int iFormId = FormId;
int iWMId = LastRecordIdReceivedViaApi;
int iNoOfRecRequired = NoOfRecRequired;
WorkMobileIntegration service = new WorkMobileIntegration();

using (WorkMobileIntegration wmservice = new WorkMobileIntegration())
{
	WMCrendential objWMCredentials = login(UserName, Password, wmservice);

    BOUserForm UserForm = new BOUserForm();
    UserForm.UserFormId = iFormId;
    UserForm.UserId = objWMCredentials.CustomerId;
    objFormData = wmservice.RetrieveNFormDataStartingAfterId(UserForm, iWMId, iNoOfRecRequired, objWMCredentials);
}