Data Sources - dynamic calculations and data export

Hello - I have some questions relating to using Data Sources:

  • What is the correct approach to make and use calculations based on values in a Data Source field? For example, if a user enters a date on a form that is stored in a Data Source row, I need a dynamic field that calculates the number of days between today and that date (with some error handling etc). In a spreadsheet this would be easy but I can’t see how this could be replicated here. Is the only approach to calculate these things on the fly, using Javascript?
  • Similarly, what’s the best approach to adding a look-up based on the Data Source value? For example, a user chooses an item from a dropdown list, and the Data Source table stores this together with a category field based on looking up the item in a separate developer-maintained list?
  • Is it possible to access a particular Data Source via an API or to export a CSV in an automated way, for example once a day, ideally via secure file transfer? This would be to faciliate back-end scripting, for example, creating emails based on a Data Source contents to be sent via a separate email service.
    Thank you!

Hi brass,

  1. The correct approach to make calculations would be to use JavaScript on the fly in the form to calculate. You can use Moment.js to do such calculations easily. Depends on where the data is shown you would have to request the data from the data source and loop through the records to calculate the difference for each record. If you are getting the data manually you can use this JS API. Data Sources JS APIs | Fliplet Developers Documentation

  2. You can use our form JS API and the DS JS API mentioned above to do this. We have a change event for drop downs which you can detect and either executes looks up against a data source.
    See: Form JS APIs | Fliplet Developers Documentation and Form JS APIs | Fliplet Developers Documentation. To see an example of this, in Fliplet Studio when you click on “Add screen” you can see the “Form with drop-down from data source” screen. Add that to your app to get an idea of the code required.

  3. You can access your data source using our REST API to do the actions you are looking for. See: Data Sources REST APIs | Fliplet Developers Documentation

Hope this helps!
Deb

Great - thank you for your reply Deb