LCS - Creating a model

Learn how to create models and add properties to models.

Steps to create a model

  1. Select the Model Icon from the left side menu in your application in Betty Blocks.

    Model Button

  2. You will see a list of any existing Models. From here you can either select the “+” button to add a new Model or select one of your existing models to work with.

    List of models

    Note that there is also a “Models schema overview” button and a “Models overview” button. The Models schema overview can be useful to view a visual picture of all of your models and how are they connected (a.k.a. an ERD for professional developers). Although you can work with the models in the Models schema overview page, we recommend that you work with the models by selecting each one individually or from the Models overview page.

  3. A dialog box will appear that will let you specific the type of model you want. Leave the “Data Model” selected as is. The Remote model and Schema model are for advanced use cases.

    Dialog Box

  4. Enter in the name of the model. Using Title case in a singular form is best, e.g. Customer,  Order, Contact, Line Item, Online Registration, etc. Select “Create model” to create your model.

  5. Once your model is created you will be on the following screen. This is the screen you will see anytime you view any of your models. There are three properties that are always there when you create your model, the ID of each record, the create date, and the last update date. From there you can add whatever properties you would like.

    Model List

    To add a new property, select the “New Property” button in the upper right of the page

    Note that there is also a “Quick add properties” button which is a streamlined way to add some fields. However, we recommend you use the “New Property” button. The Quick add properties dialog doesn’t let you add any validations or default values and is limited to just the names and property types. You also have to be really careful to save them all at the end or you will lose the properties that you entered.

  6. A sidebar will slide out. The first thing to enter for each property is its property type. There is a long list of possible choices, most of which are self-explanatory. 

    Property Type

    A full list and descriptions can be found in the Betty Blocks Documentation: https://docs.bettyblocks.com/en/articles/6353834-property-type-reference.

    Here are some of the most common ones that may or may not be clear:
    1. Text Input (single line): Anytime you need a user to type in some text this is usually the one to use. Examples are first name, last name, address, city, etc. Text fields also have a minimum and maximum length to control the amount of text that a user can type.
    2. Text Input (multi-line): Anytime you need a user to type in a larger amount of text this is the one to use. Examples are comments, feedback, description, etc.
    3. Checkbox: Use this for a single checkbox that the user can select. An example would be a checkbox for “I agree”.
    4. List: Use this for a dropdown list of choices that people can choose from. ONLY use this for choices that you create when making the list item. If you would like to have the choices come from another model then you don't need to include anything in this model. 
    5. Date, Date tIme, Time, and Minutes: If you need a date, a combo of date and time or just time then choose one of these. It will make it easier for users. Dates also have a format option which is VERY IMPORTANT to change. The default format is DD-MM-YYYY which is used in many countries where the day comes before the month. Change it to MM/DD/YYYY for the standard U.S. date format where the month is listed first. Alternatively, you could use YYYY-MM-DD if you want to emphasize the year when sorting. 
    6. Number, Number with decimal: These are useful when you only want the user to enter in a number and not allow letters or other symbols.
    7. Price: Use this when you are dealing with money. You will need to set the format for it as detailed in step 9.
       
  7. Give the new property a name, preferably using Title Case. For Example, First Name, Last Name, Address, City, State, Zip Code, etc.

    Property Name

  8. Default Value: You can just leave this set to None, or you can specify any text or default answer for a field. If you would like a default value then select the Static value button and then enter in a value. The Dynamic value button is an advanced use case where you use expressions to determine the value.

    A good example of using the Static value is setting a default date. You can use the Static value and select the "relative date" button to indicate today's date. 

    Default Values

    Apply Default When Blank: If this is not selected, the default value is presented to the user as a suggestion, but they can clear it out and leave it blank. If this option is checked then the default value will be saved even if the user clears out the input and submits it blank.

  9. Format: Several fields had special formatting that you should change. Otherwise you will not see this option. Go to https://docs.bettyblocks.com/en/articles/5596796-property-format-reference-for-numbers-and-dates for a complete list of advanced formatting.

    Property Format

    Examples for common formatting:
    1. Date and Date time. Change the format to MM/DD/YYYY for the standard U.S. date format where the month is listed first.
    2. Number and Number with decimal. Change the format to [,]. For a U.S. number format with commas. Or just use []. If you don’t want any commas.
    3. Price: Change the format to $0.00 for the standard U.S. price format.

  10. Validation: Each property type has some different options for validations, but all of them have validation. You can specify if the field is required. That is very useful to guarantee the user can’t leave it blank if that’s what you need. You can also require that it has to be unique. This is very useful to prevent duplicate names or other information.

    Validations

  11. The last step is to select the Save button or the Save and add another button to add the field.

    Your Model is now set up. 


Keywordsmodels, properties   Doc ID133788
OwnerMatt M.GroupLow Code Solutions
Created2024-01-03 08:38:47Updated2024-02-05 14:55:40
SitesDoIT Enterprise Business Systems - Low Code Solutions
Feedback  1   0