Getting started

Tutorial: a first solution

Build a small customer and orders solution, from fields to a form, a view, a workflow and a dashboard.

This tutorial builds a small solution for customers and their orders, using the maker site. By the end you'll have: an Order perspective related to Customer, views of both, a customer form with a sub-grid of orders, an order form with a lookup of its customer, a workflow that notices large orders, and a dashboard.

Before you start, run OmniCore locally and sign in to the maker site (https://localhost:5001) as dev-admin. The Development database already has the sample Contact, Customer and Staff perspectives.

1. Add the order's fields

Open Fields in the left bar. Fields live in one catalogue and are shared by every perspective that uses them, so add the ones an order needs. For each, press New field…, enter the system name, choose the type and a display name, then Save:

System nameTypeDisplay name
orderNumberTextOrder Number
orderTotalDecimalOrder Total
statusTextStatus
customerReferenceCustomer

A field's type can't change once it's saved, so choose carefully. customer is a Reference: it will hold the id of the customer the order belongs to.

2. Make the Order perspective

Open Perspectives and press New perspective…. Name it Order, then add the four fields from the catalogue. Tick required for orderNumber and customer, drag the fields into the order you want forms to show them, and Save.

3. Relate orders to customers

Open Relationships and press New relationship…. Name it CustomerOrders, with:

  • From: Customer, multiplicity One;
  • To: Order, multiplicity Many, reference field customer.

Save it. From now on the database checks that every order's customer is the id of an existing Customer, and refuses to delete a customer who still has orders. See Relationships.

4. Views of customers and orders

Open Views and make two:

  • customers over Customer, with the columns account number, first name, last name and credit limit, sorted by -creditLimit (highest first).
  • orders over Order, with the columns order number, customer, order total and status, sorted by -orderTotal.

The table under the editor shows the view as you change it. In orders, the Customer column will show each customer's name rather than their id, because it's a relationship column.

5. A customer form with its orders

Open Forms, press New form, name it customer-details, choose the Customer perspective and the Header, two columns layout card. The designer opens.

  1. Drag First name and Last name into the left zone, and Account number and Credit limit into the right.
  2. Under Relationships on the left, the designer offers Orders as a sub-grid, because Customer is the one side of CustomerOrders. Drag it into the header zone.
  3. Select the sub-grid. On the right, check that its View is orders.
  4. Save.
The customer form in the designer, with the Orders sub-grid selected.
The form designer
The form designer: the perspective's fields, relationships and web parts on the left, the layout's zones in the middle, and the selected sub-grid's settings on the right.

The form designer: the perspective's fields, relationships and web parts on the left, the layout's zones in the middle, and the selected sub-grid's settings on the right.

6. An order form with its customer

Make another form, order-details, over Order, with the Two columns layout. Put the order number, total and status on the left. On the right, drag the Customer relationship: on the Order side it's a lookup, a search box and drop-down that lists the customers view. A lookup sets the reference field, so don't place the customer field itself as well. Save.

7. Try it in the portal

Open the portal (https://localhost:5000) and sign in as dev-admin.

  1. Choose Order, press New, fill in an order number and total, search for a customer in the lookup, and Create.
  2. Choose Customer and open that customer. The customer-details form shows the new order in its sub-grid; press it to open the order.
The customer form in the portal, with the customer's orders in the sub-grid.
A customer
A customer in the entity editor: their form, with a sub-grid of their orders.

A customer in the entity editor: their form, with a sub-grid of their orders.

See The entity editor for everything the editor can do.

8. A workflow for large orders

Back on the maker site, open Workflows and press New workflow. Name it large-orders and choose to start it on an entity change to the Order perspective. The designer opens with start → Write to log → end.

  1. Select the workflow (click the canvas) and, under the trigger, tick only added.
  2. Select the connection from the start to Write to log and give it the condition input.after.orderTotal > 1000.
  3. Select Write to log and set its message to Large order {{input.after.orderNumber}}.
  4. Drag from the start node onto empty canvas to add a second connection that ends the run: with no condition it's the else, tried after the first.
  5. Save.

Create an order over 1,000 in the portal, then press Runs in the designer: the run's steps show the message, and its path is highlighted on the graph. See Workflows.

A workflow's runs, with the chosen run's path highlighted.
A workflow's runs
A workflow's runs. The chosen run's path is highlighted on the graph.

A workflow's runs. The chosen run's path is highlighted on the graph.

9. A dashboard

Open Dashboards, press New dashboard, name it orders-overview and choose Two columns.

  1. Under Data sources, press New data source and make one named byStatus of kind aggregate over Order, with select status=status, orders=cnt(), total=sum(orderTotal) and group status. Preview shows its rows.
  2. Drag a Donut chart into the left zone. In its settings choose the data source byStatus, the category status and the value orders.
  3. Drag a Card into the right zone, titled Order value, reading byStatus, value total, summary sum.
  4. Save, then open the portal's home page: the dashboard is listed there.
A dashboard in the designer, with cards, a donut and a bar chart.
The dashboard designer
The dashboard designer, with the parts running on live data while you design.

The dashboard designer, with the parts running on live data while you design.

To make the card follow the donut, add a parameter to a second data source and connect the donut's selectedCategory to it. See Designing dashboards.

10. Give a team access

Everyone so far has been dev-admin. To let a sales team read customers and manage orders, a System Admin defines a role (in OmniCore Admin → Roles, or with the API):

http
PUT /api/security/roles/Sales
Content-Type: application/json

{ "description": "Sales team", "permissions": { "Customer": ["Read"], "Order": ["Read", "Write"] } }

and assigns it to people (PUT /api/security/assignments/{subject}). In the portal they'll see Customer and Order, with customers read-only. See Roles and permissions.