Applications from scratch part 1 - Node types and fields

Use the Metrici forum to ask questions about Metrici.

To get started, read the About MetriciGetting started with Metrici and About the forum topics.

Signed in as Guest. Join

This is the first in a series of articles showing you how to create a Metrici application from scratch.

In many cases you can base your solutions on existing applications and components. However, if you want to really understand how to develop with Metrici, it’s worth following this series to understand how applications are put together.

Before you start on this guide, make sure you have gone through Getting started with Metrici. That’ll guide you through setting up an account, and how to perform basic data setup in Metrici. The getting started guide shows how to use different node types (like package and page) to set up different sorts of nodes. In this article, we’ll cover how to set up your own node types to hold data for your applications.

Because it's the first in the series, this tutorial has a loads of screen shots to show you exactly what’s going on. Don’t be put off - you should get through it all in less than 30 minutes, and then you’ll be on your way to creating your own applications.

Getting organised

Before we start creating node types, we need somewhere to put them. There are no hard and fast rules about where to keep things in Metrici, but it’s worth getting organised so you don’t lose track of where everything is.

It makes sense to keep the components for each application in their own area, so to start lets create a folder for your new node types.

Go to your home page, and click on the New button. This will bring up the new node dialog.

New dialog showing options buttons

Select the Enter reference and Shown new node after create options at the bottom to give you more control over where your new node will go, and then click on the Package node type, which is a good node type for folders, then click on New.

You’ll see you can now enter information about your new package. Let’s give it a local reference of “development”, and a name of “Development”, and click on Save.

Creating a new package

From here, you can repeat the process to create a folder inside your development folder. Create a folder for your application. In this example, we’re going to be building a fancy dress hire application, so I will give the folder a reference of “fancyhire” and the name “Fancy dress hire”.

This folder will be our development area for the new application. But node types and fields are only one part of development. Let’s create a new folder with a reference of “library” and a name of “Library” to hold the new node types and fields.

You should now have a nested folder structure (in this case Jane Jones / Development / Fancy dress hire / Library), which you can see with the breadcrumb.

Newly created library folder

Creating a custom node type

In Metrici, node types (which define the data and behaviour for nodes) are also just nodes, and you can create them like any other node. So, from inside your library, create a new node using the type Type.

Creating a new node type

We have some recommended Naming conventions for different sorts of nodes. In this case, we are creating a node type for costumes. We’ll give the node type a reference of “CostumeType” and a name of “Costume”.

A node type includes a list of fields that specify what the data will hold. This list of fields is in the “Member type list” (a member type is another name for field). New nodes automatically have a couple of standard fields, name and description. That’s a good start, so let’s give our new type a description and click on Save at the bottom of the page.

A newly created node type with default fields

Using your custom node type

Now let’s test out the node type by creating a new costume.

We’ll need a new folder to put it in. Navigate back to your application folder (in this case “Fancy dress hire”). Inside this, create a folder with a reference of “sample” and name of “Sample”, and inside this create a folder with a reference of “costumes” and a name of “Costumes”.

Your folder should look like this.

Newly created costumes folder

Now, use the New button, but click on the button next to the file type. This will bring up an explorer (known in Metrici as the OmniLink) to find your type.

Click on the   at the start of the address line. This will show you a list of high-level folders.

Listing high-level folders

Click on the   next to your account name, then Development, then you application name, then library.

Selecting your custom library

Click on the Costume type, click on Done, then click on New. Then fill in details of your costume. You can leave the reference blank and a reference will be generated automatically.

Filling in a custom type

Click on Save.

A node created with a custom type

Use the breadcrumb to return to the costumes folder.

Try using the New button again. This time it will have Costume in the In this package section, and you can use that to create another costume.

Adding custom fields

So far, we have seen how to create a custom node type and then to use it. Now, let’s add some of our own fields to it.

Use the breadcrumb trail to make your way back to the application folder, then navigate to the library.

Click on New, but this time select the Field type. Give the field a reference of “CostumeSize”, a name of “Costume size”. Check the text option and give the field a suitable description.

Creating a field of type text

Click on Save, then go back the the Library folder.

Now create another field. This time give it a reference of CostumePrice and a name of Costume price. Check the number option and save.

Return to the library folder, click on the Costume type, then click on Edit (at the top of the page).

Now you should be able to select your new field from the drop-down list on the member type list. Select the Costume size field, then click on Apply to add that field. This will give you another space in the member type list. Select the Costume price field and click on Save.

Editing a type to add new fields

You should now see your Costume type with the two new field.

Updated member type list with custom fields on it

Navigate back to the Costumes folder in the sample. Click on a costume, and then click on Edit at the top of the page. You’ll see you have two new fields, a size field that lets you enter text, and a price field that lets you enter a number

Editing a node with custom fields

When you click on Save, you’ll see the new fields.

Node showing custom fields

Setting field options

You’ve added some fields, but they aren't perfect. It would be useful to add some help text. And you don’t need multiple lines to enter a size.

Go back to the Library area, and edit the Costume price field. Go to the Options tab, click on the Instructions section, enter some useful help text, and save.

Adding help text to a field

Similarly, edit the Costume size field. Go to the Options tab, and click on the Text options section. Select a Text type of Single line text from the drop-down list, and save.

Setting text type option

Navigate back to your sample data. Now when you edit the costume, you should see a single line input and some help text for the price.

Fields options applied to an edit page

Now that you have got the hang of it, create a new Customer type.

When you are editing the type, use the Remove box to delete the description field.

Removing a field from the member type list

Add a text field for telephone number, but this time also select the Repeat option, to allow the user to enter more than one telephone number. Use the single line option.

Also add an email field. Rather than just using the Field type and setting options, you can use a pre-defined field type that has the options pre-set. On new, click on the   icon at the start of the line. Then select Library, then Field, then Text Field. Use this to create an Email field.

Within your sample folder, set up a customers folder and create a customer in that. See how you can enter multiple telephone addresses, and the email field is automatically a single line text.

New customer record showing repeating telephone numbers and single-line email

 

This first step has shown you how to set up a suitable folder structure for developing an application, how to create new node types and fields, and how to test them out.

In the next tutorial, we’ll cover how to tailor the data folders (the Costumes and Customers folders) to show your data more effectively.