Skip to content

Create A Simple Workflow

Johannes Heucher edited this page Oct 12, 2022 · 3 revisions
Main page: First Steps
In this section we will learn how to create a simple Workflow called "Add New Car". The background is that there should be a database of cars which an auto dealer has in-stock. One function of the system is to add new cars to the database. Every car has a unique Vehicle Identification Number (VIN), so we will make sure each added car's VIN is not already in the database.

Table of Contents

Create a Data Type for "Car"

A data object (Data Type) can be thought of as a data structure in traditional programming languages. Here we define it partially visually instead of only via text. The Data Type window and functionality are discussed in detail in Data Type. On the left side of the modeller is a sidebar with various buttons. The top one is used to open new Workflows, Data Types, etc. Click on this button to see a drop-down menu where you can select what type of object you want. Select Data Type. A tab window will be opened where you can configure the Data Type. thumb
Change the text in the Label field to "Car". The Path field tells the modeller where in the system to store this Data Type. This groups various Data Types, Workflows, etc, into functional groups explained in Xyna Factory. For this exercise, change the Path to "xdev.test" by typing or selecting path parts in the drop-down you will see. The Documentation field can be used to describe the Data Type. In order to define the individual variables in this Data Type, click the button behind Variables. This adds a new Member Variable called "Data". Click on the variable to modify it. Change the text in the Label field to change it's name to "Make". The text in the Name field is set automatically. You can change the type of the Member Variable in the Data Type field by typing or select Data Types in the drop-down. For this exercise, keep the default Data Type "String". The Documentation field can be used to describe the variable. Repeat this to add variables: "Model", "Year", "Color", "Options", "VIN". thumb
A car may have more than one Option, so we can make this variable a list (or array) of Options. Click on the "Options" Member Variable, then click on the "1" behind the Data Type field to toggle multiplicity. You will notice that the Member Variables shown on the left have a "1" for a single variable and an "n" for a list variable. Deploy the new Data Type by clicking the deploy button on the left sidebar. This makes the Data Type usable in Workflows or in other Data Types. thumb

Make the Data Type so it can be stored in the database

In order for a Data Type to be used as an object to be stored in the database, it must be a Storable. To do this, enable the "Storable" checkbox in the upper area of the Data Type. The Base Type automatically change to xnwh.presistence.Storable. Click the Deploy button in the left sidebar again to save and deploy the Data Type. thumb

Open a new Workflow

A Workflow is a collection of various steps which perform a task. The "flow" of the steps goes from top to bottom. The Workflow window and functionality are discussed in detail in Workflow. To open a new Workflow, click again on the new button at the top of the left sidebar and select Workflow. This will create a new tab called "New Workflow". thumb

Name the Workflow

To change the name of the Workflow, click on the words in the middle of the title bar and type "Add New Car". The name should be descriptive of what the task will do. Add New Car

Add Input and Output Parameters

A Workflow does not have to have any Input or Output Parameters (objects), but most of them do. In our "Add New Car" Workflow, we will have a "Car" Data Type object as input as well as output. The input will contain the data which represents a new car for our database. The output will be the same as the input, except when Make, Model or VIN are not set. Then we will return a null "Car" Data Type to inform the caller that data is missing. To add an Input Parameter, first look for the "Car" Data Type in the Factory Navigation under the path "xdev.test". Or use the Search area to search for "car". You will see the "Car" Data Type in the list along with it's path "xdev.test.Car". Drag this Data Type from the list to the top of the Workflow window. Drop the "Car" into the space above the title bar called "Input Parameter". Now it appears at the top left of the Workflow window. To add a "Car" Data Type to the output of the Workflow, drag the "Car" again from the search list into the "Output Parameter" space at the bottom of the Workflow window. Your Workflow should have "Car" at the top and bottom now. thumb thumb

Document what the Workflow does

A description of what the Workflow does, how it works, what the input and output will be, etc, can be typed into an info area at the top of the Workflow. To open up the info area, click on the Context Menu at the top right of the Workflow window and select Show/Hide Documentation. Type in a useful description of the Workflow. You can select Show/Hide Documentation again to close the documentation area. thumb

Add the specific steps to perform the task

Next: Testing Workflows
Clone this wiki locally