Custom Model Reference
In this article
This article contains all the information you need to know about each setting within the Custom Model page.
Robert van Boesschoten
Last updated: 17-10-2019
A custom model is used as a framework(, or handler) for temporary (JSON) data, mostly data received from webservices, pages or actions. It's basically a model that's isn't implemented in your data model, as it wouldn't actually store records. It’s used to store sets of data in an object or collection, instead of using multiple variables, each containing their own JSON value. This’ll help avoid confusion once your application starts getting large and makes it easy to assign the values to action event or UI components. You can find all your custom models via Tools > Custom models.
The navigator is the black bar at the top of your screen.
Here’s what everything does:
New: This button opens a window where you can create a new custom model.
Question mark [ ? ]: By clicking this button, a new panel pops-up. This panel has a small video that shows you how to create a new custom model, as well as links to some helpful articles.
Column headers: You can click on these to sort custom models by name or model in alphabetical or inverse order.
Search bar: Here you can search for custom models by name or model.
Refresh: By pressing `R` on your keyboard or the Refresh button in the footer to refresh the overview.
You can create a new custom model by pressing the New button, or by creating one based on a web service response. You can see how to use the latter way to make one here: HowTo create a custom model?
< Close: Pressing this closes the current form. This does not automatically save!
Name: Give your new custom model a name.
Attributes: Once you’ve created your custom model, you can add attributes to define its contents.
Save: Click this to save your new custom model.
You can edit your custom model by pressing the Edit button.
When pressed, you’ll see the edit page for the custom model. Here, you can change its name and see what depends on it.
Name: Here you can rename your custom model. If you rename your custom model, it can affect parts that depend on it. Make sure to check the dependencies first!
Dependencies: You can see what relies on this custom model existing in order for it to work here. Helpful when trying to see whether or not it’s safe to delete. More information about dependencies can be found here: What are Dependencies?
You can view and start adding or removing attributes by clicking on the Attributes button. You can also press the `+ button to immediately start creating a new attribute.
This is where you can set up the contents of your custom model. When you first open this screen there won’t be any attributes yet, unless this custom model has been generated as part of a web service.
< Close: You can press this to go back to the custom model’s overview.
+New: You can press this to create a new attribute.
Question mark [?]: By clicking this button, a new panel pops-up. This panel has a small video that shows you how to create a new attribute, as well as links to some helpful articles.
Search bar: Here you can filter attributes by name, kind or property.
Column headers: You can click on these to sort attributes by name, kind or property, in alphabetical or inverse order.
Attributes: By clicking on one of these you’ll be taken to that specific attribute’s detail screen.
Refresh: By pressing `R` on your keyboard or the Refresh button in the footer, you can refresh to make sure there aren’t any attributes missing on your page.
When you press the `+ New` button, you’ll see a screen that looks like this:
Here you can select what kind of attribute you want it to be and whether or not you want to validate its presence. There are four kinds of attributes: Linked, unlinked, collections and custom models.
Unlinked attributes are fairly simple to make, as all they require is a name. Your validation options are limited to their presence, however.
Kind: Here you can select what kind of attribute you want it to be. Unlinked properties can be a checkbox, date, date time, decimal, file, number, or a text field.
Name: Here you can give your attribute a name.
Validations: Here you can validate your unlinked attribute’s presence. This means that Betty Blocks will throw an error when this attribute doesn’t get any information whilst in use.
These attributes are slightly more complicated than an unlinked one, but they’re still fairly simple.
Kind: Should be set to “Custom model”.
Name: You can give the attribute a name here.
Validations: Here you can validate its presence and then validate the custom model.
Custom model: Here you can select what custom model you want to be using for this attribute. You can select any you’ve made, including the one you’re in, or you can make a new one. You can edit the new model by pressing the Custom model button after saving it.
These attributes can be used to refer to a collection of custom models or attributes.
Kind: Should be set to “Collection”.
Name: Give your collection a name here.
Construct: Here you can select what the collection should be of. You can select attributes, in which case it’ll collect all of those, a custom model, or make a new custom model by selecting `- New -`.
Validation: You can validate the construct and the presence of this attribute here.
These attributes are linked to a model’s property. You get a load of extra validation options when using these.
Kind: Should be set to “Linked property”.
Name: You can give it a name here.
Model: Here you can select the model the property is related to.
Property: You can select what property you’d like to retrieve here.
Depending on the property, you’ll get a different set of validations. These are the same as the property’s standard validation rules. You can find more about how to validate your properties here: HowTo setup advanced property validations.
Inherit property-validations: You can check this to validate the property like you usually would, were it a part of the normal model.
You can edit a custom model by pressing the Edit button at the top right of their details screen. This’ll send you to the same screen as when you first made your attribute, and you can edit it there.
You can use custom models in endpoints and actions as a source of input and output of data. This is a great way to trim down your input variables by turning them all into one custom model instead. You can find more about using custom models here: What are custom models?
In this article