Skip to main content
All CollectionsTools
How custom models are used
How custom models are used

What Custom Models are and how they can be created from different points in your application as well as how they can be used is explained.

Betty Blocks avatar
Written by Betty Blocks
Updated over a week ago

Warning!

This is a legacy document. The features described below are only usable within the classic-generation environment.

Currently, Betty Blocks offers faster and more advanced options that are available in next-gen. Before you start working on some new features in your application, consider doing it using the next-gen version. In particular, you might find it useful to check out Using the HTTPS action step and Setting your remote data source articles.

Good luck!

This article contains the following sections:

  • About Custom models

  • Using endpoints as custom models

  • Using custom model with a POST page

  • Using custom models with GET responses

  • Using custom models for testing webservices

  • Using existing models for custom models (deriving custom models)

About Custom Models

Custom models can be used to store sets of data in an object that is not implemented in your data model. You can use it for organizing transmitted data or for organizing variables that are used in your application.

Custom models can be used in endpoints and actions as a source of input and output data. You can also manage input variables by absorbing them in a single custom model.

You can open Custom models, open the Tools (A) menu and select Custom models (B). The platform window for our previous environment is opened and any existing custom models for the application in which you work are displayed (C).

Note: You may be requested to enter your user name and password details even though you are already logged in on the platform.

You can create a custom model by clicking on the New button or using the JSOn response from a web service.

Using Endpoints as custom models

If your endpoint contains a form of data input (e.g. a form), you can save this as a single custom model instead of several different variables. This supports ensuring that you have a single point for managing data used in an Action.

Using custom model with a POST page

To ensure a simplified structure, you can also use a custom model when creating the POST page for your application for capturing all the fields in a single variable. See Using HTTP methods on web pages for additional details.

If you go to your POST page and add a new input variable, you can choose a custom model as a type. You can select an existing model or create a new model. Where you create a new model, you can select the properties from the model on which it is based. Once complete and you have saved the required POST page, you can access your custom model for use as an object in the associated Action

Using custom models with GET responses

You can use custom models to accept the data from a form. This means that a single point of reference is used for the results of the form. The following syntax is required:

custom_modelname[attribute]

For example, if you create a custom model, based on your Contact model with the name cm _contact and the model's property as first_name, your input tag is:

When you assign input fields with the correct name, you can locate the variable on the post page within the custom model used as the input variable and specified in the GET request.

Using custom models for testing webservices

You can use the Generate custom model button to create a model based on a response for testing a web service.

When you click Generate custom model, a custom model is created, based on the details contained in the body of the response. The custom model attributes search to match for their type. A match can belong to another (nested) custom model. Where you find the type selected incorrect, you can edit the details applied.

The custom model can now be used in actions. It speeds up the process of building a webservice as each individual variable does not have to be fetched using text expressions. This also reduces the possibility of errors.

Using existing models for custom models (Deriving custom models)

Derived custom models are based on (derived from) existing models from your data model. Derived custom models can be created as input variables, and are useful when building form pages with multiple input fields.

For example, where you have a registration form for your contacts and a Contact model with the properties firstname, lastname, email, address, zipcode and city. You can build a registration form that resembles the following example:

Note: This example is based on an application template. Check out templates via My Betty Blocks (https://my.bettyblocks.com/templates)

Did this answer your question?