Parametrize Workflows – Use Input and Output Arguments

When you create a workflow, you commonly intend to make a process repeatable and executable with a single click. This is great if you want to pack your workflows in an app for Soley Desk or Soley Server or if frequently have to re-run your analyses, e.g. if the input data is updated! To allow for user interaction when running a workflow all workflows can be parameterized. A parameterized workflow requires the called rules and sequences to be parameterized as well.


1. Step – Parametrization of sequence

We show the parametrization of sequences using the example of a sequence that imports instances from an Excel file. The usage of the Data_importNodesFromTable library element is explained here. Instead of assigning a fixed path to the input data table and a fixed sheet name, two parameters are introduced. In line 2, two input parameters of type string are defined and then used in line 4.

Example code:

1 //Sequence to import and create part node instances
2 sequence importParts(tablename:string,sheetname:string) {
3   Data_importNodesFromTable (
4       tablename, 3, 1, -1, -1, sheetname, "", "Part", map<int, string>{
5           1 -> "id",			//map value found in first column of Excel sheet "Parts" to the attribute id
6	    2 -> "name",		//map value found in second column of Excel sheet "Parts" to the attribute name
7	    3 -> "parent",		//...
8	    4 -> "cost",
9	    5 -> "weight",
10	    6 -> "quantity"
11      }
12  )
13 }

2. Step – How to call a parameterized sequence

If we want to run the sequence, we have to call it with the respective input parameters, e.g. as part of a super sequence. Example code:

1 //Sequence to run two part imports 
2 sequence importData{ 
3     importParts("..\\..\\Data\\MyData.xlsx","Parts")
4 }

3. Step – Create and assign arguments to parameterize workflows

In the last step, the workflow is made accessible for parametrization. Therefore, we open the workflow in the workflow editor.

3.1 The input arguments are the interface between the user and the coded import sequence. We open the Arguments selection in the bottom navigation bar. We press Create Argument to set the arguments. You can define the argument type, such as String or Int32, if it is an Input or Output argument (we need In) and you can define a default value. Please note that strings have to be given in quotation marks, as shown below. For our example, we require two arguments that we can freely name, e.g. sheetnameParts to define the name of the sheet containing the Part nodes, and partTablefile to define the relative path to the Excel file.

Arguments section of the Workflow editor in Soley Studio with some input arguments defined
The Arguments section of the Workflow editor with some defined input arguments

3.2 In a final step we add the arguments in the sequence call that is done in the Run Transformation activity. Do not forget to use curly brackets around an argument to pass the string.


3.3. After saving the workflow and selecting it in the Workflow Launcher tool it can look as follows:

Workflow Launcher tool of Soley Studio or Soley Desk showing a selected workflow that asks for string type input arguments and offers file picker buttons
Workflow Launcher tool showing a workflow with input arguments incl. file picker

Note that we edited the Display name of the arguments to be better readable.

4. Step – Browse for File or Folder Button

When the argument is a path referring to an existing file or folder, you can add a browse for file- or browse for folder-button. To do so, you simply have to name the string argument ending with either …file or …folder (e.g. import_file, importfolder, … ). This way the file- or folder-picker (… button) appears next to the argument in the Workflow Launcher. This button opens a Windows Explorer dialog in which files and folders can be picked. Once selected, the path to the file or folder appears as a string in the argument field.


Was this article helpful?

Related Articles