Creating Defined Data Structures (Advanced)

Last Updated: 05/03/2018 Introduced in Version: 2.0

Custom data structures represent real or abstract objects by their use of data members. Data members are basic units of information that can be thought of as variables belonging to the object you wish to represent. Custom data structures can be created in the folder System > Designers > Data Structures.

Example

In this example we will:

  1. Create a defined data structure.
  2. Add data members to the data structure with data types of string, Boolean, integer, and Date Time.
  3. Set how the data structure can be saved.

Our example data structure will be called UserInfo and contain variables of demographic information not already represented by User Accounts, including: first and last name, address, sex, age and date of birth.

Data structures are contained in the folder System > Designers > Data Structures. Some structures are common variables available to a programmer like integers, bytes, boolean, strings, and others. These structures appear throughout much of the platform and have no members. In fact, they are the data structures we will typically use as members for more complex structures.

At least two of these complex structures are already defined: Decisions and DecisionFramework. These data structures are like custom structures because they rely upon data members to define their properties. The key here is that data structures can be nested inside each other. This allows us to create data structures of nearly unlimited complexity.

To begin building our example data structure, we will click the button Add Defined Data Structure.

A custom data structure has only a few components: a name, a namespace and super class (both of which are described in other examples), data members, and an option for storage. We’ll begin by naming our custom data structure “UserInfo” and assigning it members.

We enter a name in the Structure Type Name field and then populate our data structure with data members as follows.

Our first data member will be called FirstName, and will contain our user’s first name. In computer programs, words and sentences are represented as strings of characters, hence the name Strings. Once we’ve declared a name and type for FirstName, we will repeat the process and add two more data members, LastName and Address. Enter their names and select their data types as String.

Our next data member, Sex, is a little different. For our example, we would like to represent Sex as either “Male” or “Female.” When we want to restrict a variable to only two possible values, our best option is to make its type Boolean. A boolean variable can only be true or false. Later, we can programmatically associate “Male” or “Female” with “True” or “False”, but the way that we have it set up now is fine.

To change the data type to Boolean, we click the Data Member Type selector, select the data type from the list, then click OK. For Age, we want to restrict our variable’s value to whole numbers only. The platform offers multiple numeric types, but the most appropriate for our example is the 32-bit encoded integer, or Int32.

Our final data member, DateOfBirth, must be a valid calendar date. We could represent the date as a string, but the DateTime type comes with special validation and encoding rules that prevent invalid dates, such as February 30th, from being saved.

 

Now that all of our data members are added, we need to define how our data structure can be saved. This can be done in the Storage Option drop down list. We want to be able to save this structure, so we will change the value to DatabaseStored and click SAVE to save our custom data structure.

 

This completes the creation of our custom data structure. It now appears in our list of available data structures, and can be used anywhere in the platform.

 

If we examine the details of our data structure, we can see it contains the data members/properties that we added.

Should we decide later on to modify or even delete our custom data structure, menu options are available to handle that procedure.

 
 

Additional Resources