Workflows are an option to fully automate processes in Soley Studio. This article shows how to create workflows (*.slwf files) from scratch.
Table of Contents
Types of Workflows
There is a very wide range of activities that you can perform with workflows, but the most common are to execute some part of your code, maybe with some user interaction to input parameter values, visualize results in certain views or emit pop-up messages. In most cases the two different structures that we included as templates cover your basic needs:
To create an empty workflow right click on the Workflow folder in the Solution Explorer, click Add… and then New File. Choose the Workflow folder and then either select Empty Workflow, Start with Current Graph or Start with Empty Graph. We recommend using one of the Start With workflow templates, which contain a basic activity sequence starting either with an empty graph, e.g. to import data or with a currently existing graph, e.g. to run an analysis on previously imported data. Then click on Create. This will create a *.slwf file and a *.slmd file of the same name in the Workflows folder of your current project. The *.slwf file is the actual workflow. The *.slmd file is the XML description of the workflow that will show in the Workflow Launcher tool.
After creating a new workflow the workflow builder will open. Depending on the template you selected the central window can be either empty (Empty Workflow template) or contain so-called Activities (Start With Current Graph or Start With Empty Graph templates).
Workflows are being built by dragging and dropping Activities from the list on the left side to the canvas in the middle, which is called Activity Builder. Due to the available amount of different activities, the easiest way to find a matching activity is to search for them using the Search field. Here you can find a complete list of all workflow activities with a short description. The sequence in which the activities are arranged on the canvas from top to bottom defines the execution sequence.
If you select an activity on the canvas you can see the properties of this activity on the right side. Some of these properties must be set, others are optional. By hovering the mouse over the field you will be informed about the required content. A red exclamation mark will indicate an incorrect setting. By hovering over the symbol you will be informed about the error. Figure 2 depicts the user interface of an *.slwf file with the already mentioned Activities, the Activity Builder, and the activities properties section.
Variables and Arguments in Workflows
Most workflow activities require variables, at least one to store the current data view and one to store the current graph. In both prefilled workflow templates the required variables are already present. If you start with your workflow from scratch you will need to create a variable of the type IDataViewContent, which you can call dataView, and a variable of the type IGraph, which you can call graph.
Input and Output Arguments
Just like code elements, workflows can make use of input arguments. These arguments can be set by the user running the workflow and allow for user interaction, e.g. to define paths to import data from or to issue query terms. To create a workflow argument click on the Arguments tab in the bottom of the Activity Builder. In this section click on Create Argument to create a new argument. You can select the direction (In or Out) and the type of the argument (Int32, String, Double, Array …). The list of types is excessive. You can find the supported ones in mscorlib –> System. To learn more on how to parameterize a workflow with input and output arguments, please see this article.
Edit the Description of a Workflow
Every workflow has a markdown description file (*.slmd file). The content of this file defines how the workflow appears in the Workflow Launcher pad. This includes the name and categorization of the workflow in the list of available workflows and the description showing in the description section. Learn all about editing the *slmd file here.
Make your Workflows Ready to be Used in Soley Desk
If you create a workflow from scratch, i.e. by starting the Empty Workflow template, you need to keep in mind if the workflow has to be executed in Soley Desk, too. In Soley Studio you can run workflows without having a graph file open while in Soley Desk you will always have a graph file open. Thus, you need the CreateViewFromStartupProject and SetGraphToView activities if you run a workflow in Soley Studio while you need a GetCurrentDataView activity in Soley Desk. Both cases can be covered using an If condition in the workflow.
- Drag and drop an If Activity in the sequence and use the following If statement:
Soley.Framework.SDK.Services.AppService.IsItDeskIn the Then field, drag and drop the activities that apply for Soley Desk, e.g. GetCurrentDataView . In the Else field, drag and drop the activities that apply for Studio, e.g. CreateViewFromStartupProject. Such an If- Statement can look like depicted in Figure 3.
Keep in mind, that this case separation also has to be made when viewing the graph in the end. Please see the filled out workflow templates for more details and examples on this.
If you keep this separation in mind all your workflows are ready to be deployed as part of an app for Soley Desk. You can find out how to create an app from your Soley Studio project here how to create one!