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 name | Type | Display name |
|---|---|---|
orderNumber | Text | Order Number |
orderTotal | Decimal | Order Total |
status | Text | Status |
customer | Reference | Customer |
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 fieldcustomer.
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:
customersover Customer, with the columns account number, first name, last name and credit limit, sorted by-creditLimit(highest first).ordersover 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.
- Drag First name and Last name into the left zone, and Account number and Credit limit into the right.
- 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. - Select the sub-grid. On the right, check that its View is
orders. - Save.
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.
- Choose Order, press New, fill in an order number and total, search for a customer in the lookup, and Create.
- Choose Customer and open that customer. The customer-details form shows the new order in its sub-grid; press it to open the order.
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.
- Select the workflow (click the canvas) and, under the trigger, tick only added.
- Select the connection from the start to Write to log and give it the condition
input.after.orderTotal > 1000. - Select Write to log and set its message to
Large order {{input.after.orderNumber}}. - 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.
- 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.
9. A dashboard
Open Dashboards, press New dashboard, name it orders-overview and choose Two columns.
- Under Data sources, press New data source and make one named
byStatusof kind aggregate over Order, with selectstatus=status, orders=cnt(), total=sum(orderTotal)and groupstatus. Preview shows its rows. - Drag a Donut chart into the left zone. In its settings choose the data source
byStatus, the categorystatusand the valueorders. - Drag a Card into the right zone, titled Order value, reading
byStatus, valuetotal, summary sum. - Save, then open the portal's home page: the dashboard is listed there.
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):
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.