Storing and Accessing Data
Last updated
Was this helpful?
Last updated
Was this helpful?
Airkit allows you to collect, use, modify, and remit data.
Data is information that can be stored or used in your application. Data in Airkit has many different . Data can be simple types like or , complex types like or , or objects with a customized structure, such as or .
Data can be collected from a user or stored in App and used as a configuration.
Variables are one way to store and access Data. Variables can be defined at different scopes to have different availability throughout an application. The data held in a variable reference can be changed throughout the lifetime of the app based upon events and actions.
Defining Variables in Namespaces and Scopes
Namespaces refer to regions where we can store data. Scopes are how we access variables in each of the regions. For a detailed understanding, please check out this document on . There are several different variable scopes for working with data. Some of them include:
Session - accessible anywhere throughout the app builder and journey builder. They are tied to a specific user's journey.
Defining variables at the session level happens in . Click on the canvas and the inspector will show available session scoped events.
**ActivityGroup -**accessible to any web page, action, or event within a specific .
To create a variable on a Web Flow, go to and select a Web Flow in the Tree. In the Inspector under the Variables section, there is a list of available ActivityGroup scoped variables and a button to add new variables.
Activity - accessible to any event or control on a given web page.
When referring to a variable without a scope in a Web Flow, the runtime will attempt to find the variable in the most specific level and work up the chain, checking in activity, then activityGroup, then in session. It is possible to have variables named the same name in multiple scopes so it best to be specific when referring to your variables.
Accessing the Data
Defined data can be used in expression editors throughout the experience. In this case, the activityGroup variable activity_group_name is used to set the text for a label.
Seeing AirData in AirData Builder
Clicking into a table cell will allow modification of data. Once a row has modified data, it will highlight in a light yellow. Changes will be committed on the next save. Add new rows by clicking on the cell to the right of the Newtext. New rows are highlighted in light green. Just like modified rows, changes will be committed on the next save. Clicking the trash can at the left of a row will mark the row for deletion on the next save.
Retrieving Data with Data Flows
The result of this transform would be all of the teachers who have a value of years_teaching greater than five.
Using Datastores
In this example, the text is retrieved from the user and passed to the subsequent Web Page to be displayed.
Data might need to be transformed, actually as it was in the example above. In order to create the Text for the Text Label with the name, the Expression editor for the greeting text contained:
To create a variable on a Web Page, go to and select the Web Page from the Tree. In the Inspector under the Variables section, there is a list of available Activity scoped variables and a button to add new variables.
Updating values in variables can be done through on an action or event. This action can happen when a user takes an action, such as entering data into a form, clicking on a button, or responding to a text or voice prompt. Because this action uses an expression editor, Airscript can be used with properly scoped variables in updating variable values.
AirData is a datastore tied to an app's profile where records can be stored for collection or retrieval. Use to look up and store your records into . Airkit Studio has a bunch of ways to work with data stored in AirData.
The data stored in AirData can be viewed in the . Selecting an object in the Tree will show you the data already in the AirData Table.
Data from AirData can be accessed through in . To retrieve data from the above table, create a new Data Flow in Connections Builder. Select from the dropdown for the first . The above AirData App Object is named Teacher, so select that from the dropdown.
Clicking Play on the Data Operation will return the query results from the AirData table. In the picture above, there were 5 teachers in the Teachers AirData table. Returning the entire response is possible at this point, but it is also possible to filter out the results by creating another Data Operation of type . Writing something simple like:
will return only the resulting array. Returning the result of the transform will return a of Teacher Objects. In addition, additional filtering of the list can be done in the Transform using Airscript's to pull out all teachers who have been teaching for at least five years.
AirData is stored in . Datastores are collections of AirData that are kept in a specific environment. Different can use different Datastores. Each datastore will have its own version of AirData. Create a clone of a Datastore, which is useful when setting up environments for testing. When an app is created, a Datastore is created with it. Switching the Datastore can be done in .
External system data can be retrieved, modified, and updated through . This data can be used throughout your App. Our can be used to fetch data from any HTTP API. Once data is ingested into the App through the connection it can be treated like any other . For detailed instructions on how to get external data, check out .
There are two main categories of data in the Studio. Data that needs to be gathered from a user and data that needs to be displayed. Gathering data is about creating . When we create a on a *Web Page,*Airkit automatically creates a data binding to a text variable on the page. This variable can be displayed on the existing paged, passed to an action like a Data Connection, or an Event. The data can also be passed to future Web Pages in the journey:
In Addition to viewing, Data can be sent to or external systems through .
This is an example of using an escape sequence in the string for the Label to Insert some AirData. There are more examples in .
More complicated transformations of data are better done in in using the . This operation can be used for many different things, check out the documentation for more information.