Follow

Creating and Updating Rows in a Data Source

Creating and Updating Rows in a Data Source : Support

Often you may want to allow the user to create and edit rows in one of your Data Sources.

This is supported on our platform by setting up a Form in the way described below.

 

Let’s assume you have a data source called "Projects", and you want to use a Form called "Project Editor" to add/update rows in the Projects data source.

 

  1. Open the Form designer for your Project Editor form, make sure you have an editable Draft/Test version.
  2. Ensure you have a Choices field on your Form, which is set to use the "Projects" data source.
  3. Tick on the "Create/Update Row" property on that field.
    This instructs the Form to create/edit the selected row from your Choices field.
  4. Add some fields - one for each column that you want to allow to be edited on the Projects data source.
    On each of these fields make sure you set the "Bind to Data Source Column" property to assign that field to be bound to the specified column.
    This binding means that the selected row's value for the given column will be set into the field, and also any edits in the field will be written back to that column.
  5. To enable the creation of a new row in the data source, you must have a "dummy" row in your data source which has it's first column value set to 0.  
    This way the user can select this row from the list to add a new project.
    The app is also coded to treat 0 value rows as being a new row, and it will auto-generate a 36 character unique key (a GUID) for the row to ensure uniqueness.
  6. We recommend you also set the displayable title column of this dummy row to be something like "Add new project" or something like this.
    This will make the purpose of the dummy row clear to the user.
  7. If you want the dummy row to always be visible as an option on the Choices field, then set the Default Value property to 0 and tick on the Always Show Default Option property.

 

Once you have implemented the above, test out your Form to see the results.
Try selecting an existing row and editing it, and also try creating a new row.

 

The Projects data source will be automatically updated with the new row/edited row, both on device and then on the central data source on the web platform, once the form has been completed and uploaded.

 

If the Data Source you are updating is supplied to the app via a Hosted GET, then read on to review the integration considerations involved.

 

Otherwise you can stop reading right here - you're all done.

 

Hosted GET Considerations When Creating New Rows

 

Here's what happens when a new row is created on the app:

 

  1. A new record gets created with the Form Entry Id as the row's identifier in the local app-side Data Source copy.

This is done to give a consistent user experience, in that the user can see the new row they created any Data Source listings immediately after completing their creation Form entry.

 

  1. When a Hosted GET is involved, we expect your system to receive the new Form Entry (e.g. via a REST connector on the Form), process it and check whether the Choices/Data Source field value matches the Form Entry id.

If your service finds this, then your system knows that this entry created a new row and you can process accordingly, creating a matching new row on your system with a new system assigned id.

 

3a. If your Hosted GET does a full replace of rows on every call from the app - i.e. using the Rows property on your responses -  then you're done, nothing more to do.

The next Hosted GET sync will clear all existing app rows (including the one stored locally with the Form Entry id) and replace with your system's rows (including your new system assigned row).

 

OTHERWISE

 

3b. If you are making incremental updates on the Hosted GET - i.e. sending NewRows and DeletedRows back on your responses - then there is still the matter of removing the local app created new row identified by the Form Entry id, and adding your new system assigned row.

 

So when receiving the Form Entry on your web service, you will need to track the user's device id and Form Entry Id for use by your Hosted GET service, since you need to replace the app's local new row with your system assigned new row.

On next app sync from the user's device (identified by their device id), your Hosted GET should then send a DeletedRows value containing the stored Form entry id, along with a NewRows value containing the new system assigned row values.

This will cause the app to delete the local entry id based row, and add the new system assigned row.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk