You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/extensibility-api/csharp/extensibility-api-howtos/create-microflow-service.md
+39-25Lines changed: 39 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,19 +7,16 @@ weight: 14
7
7
8
8
## Introduction
9
9
10
-
The `IMicroflowService` is the service used to perform actions related to microflows. This how-to describes how you can create a new microflow and add some activities to it.
10
+
This how-to describes how to create a new microflow and add activities to it. The `IMicroflowService` is used to perform actions related to microflows.
11
11
12
-
## `Initialize`
12
+
## Creating and Initializing a Microflow Using `Initialize`
13
13
14
-
The `Initialize` method initializes a microflow that was previously created. It is part of a series of steps required for adding a microflow to the model:
14
+
The `Initialize` method initializes a microflow that was previously created. Follow the steps below:
15
15
16
-
1. Start a transaction (`IModel.StartTransaction`).
17
-
2. Create a microflow and add it to the module (`IModel.Create<IMicroflow>`).
18
-
3. Call `IMicroflowService.Initialize`.
19
-
20
-
Internally, the `Initialize` method sets up the start and end flows, and adds any parameters that might be passed in (in the example below, you are passing a single parameter `boolParameter` of `DataType.Boolean`).
21
-
22
-
In the example below, you also add activities to the microflow, with `IMicroflowService.TryInsertAfterStart` (adding an activity as the first) or `IMicroflowService.TryInsertBeforeActivity` (adding an activity before another).
16
+
1. Start a transaction using `IModel.StartTransaction`.
17
+
2. Create a microflow and add it to the module. Use `IModel.Create<IMicroflow>` to create the microflow and add it to the desired module.
18
+
3. Initialize the microflow by calling `IMicroflowService.Initialize`. The `Initialize` method sets up the start and end flows, and adds any parameters (for example, `boolParameter` of `DataType.Boolean`).
19
+
4. Insert activities into the microflow using `IMicroflowService.TryInsertAfterStart` to add the first activity, and `IMicroflowService.TryInsertBeforeActivity` to insert activities before others.
As you can see, this `IMicroflowService.Initialize` method can be cumbersome to use, since it is only part of the whole process of creating a new microflow. To have an easier method of creating microflows, use the `MicroflowService.CreateMicroflow` method. This method is described in the next section.
47
+
Note that this `IMicroflowService.Initialize` method requires multiple manual steps. For a simpler approach, use the `MicroflowService.CreateMicroflow`, described in the section below.
51
48
52
-
## `CreateMicroflow`
49
+
## Creating a Microflow Using `CreateMicroflow`
53
50
54
-
The `CreateMicroflow` method is the more advanced and comprehensive method to create microflows. It is a good alternative to the `IMicroflowService.Initialize` method.
55
-
The `CreateMicroflow` takes care of initialization and adding everything to the model in one single step. It requires the current `IModel`, the `IFolderBase` (module or folder) in which to save the microflow, a name, an optional `MicroflowReturnValue`, and an optional list of parameters. See the code below for a few examples.
51
+
The `CreateMicroflow` method is the more advanced and comprehensive method to create microflows. It is an alternative to the `IMicroflowService.Initialize` method. The `CreateMicroflow` method handles initialization and model integration in one step. It requires:
52
+
53
+
* The current `IModel`
54
+
*`IFolderBase` (module or folder)
55
+
* A name
56
+
* Optional:
57
+
*`MicroflowReturnValue`
58
+
* List of parameters
56
59
57
60
### Creating a Simple Microflow
58
61
59
-
As shown in the code below, all that is required to create a microflow and add it to the model is the`IModel`, the `IFolderBase` in which to add the microflow, and its name.
62
+
As seen in the code below, the only requirements are`IModel`, the `IFolderBase`, and its name.
60
63
61
64
```csharp
62
65
publicvoidCreateMicroflow(IModelcurrentApp)
@@ -73,7 +76,7 @@ public void CreateMicroflow(IModel currentApp)
73
76
74
77
### Creating Microflow with Return Type and Parameters
75
78
76
-
In this more advanced example, you will see the `IMicroflowExpressionService.CreateFromString` method, which allows you to create expressions that can be then used as the `MicroflowReturnValue` of the microflow. Here, the expression is a simple addition of two values, and the return type is of `DataType.Integer`.
79
+
In this more advanced example, you see the `IMicroflowExpressionService.CreateFromString` method, which allows you to create expressions that can be then used as the `MicroflowReturnValue` of the microflow. Here, the expression is a simple addition of two values, and the return type is of `DataType.Integer`.
77
80
78
81
```csharp
79
82
voidCreateMicroflow(IModelcurrentApp)
@@ -88,36 +91,47 @@ In this more advanced example, you will see the `IMicroflowExpressionService.Cre
88
91
}
89
92
```
90
93
91
-
The `IMicroflowService.CreateMicroflow` method is a bit easier to use than the `IMicroflowService.Initialize` method because it doesn't require manually creating the microflow with `IModel.Create<IMicroflow>` and then manually adding it to the `IFolderBase` container. It can do everything behind the scenes as long as everything is supplied to it. For a comprehensive example on how to create microflows, see [Create Microflows for Calculations Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/create-microflows-for-calculations/).
94
+
The `IMicroflowService.CreateMicroflow` method does not require manually creating the microflow with `IModel.Create<IMicroflow>`, then manually adding it to the `IFolderBase` container. For a comprehensive example on how to create microflows, see [Create Microflows for Calculations Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/create-microflows-for-calculations/)
95
+
96
+
## Inserting Activities
92
97
93
-
## `TryInsertAfterStart` and `TryInsertBeforeActivity`
98
+
Use the following methods to insert activities into microflows:
94
99
95
-
The `TryInsertAfterStart` and `TryInsertBeforeActivity` methods enable inserting an activity in the flow. It can be added right after the start event of the microflow, or be inserted before another specific activity.
100
+
*`TryInsertAfterStart` – adds an immediately after the start event
101
+
*`TryInsertBeforeActivity` – inserts an actvitiy before another specific activity
Use `GetParameters` method to retrieve all the input parameters of a microflow.
111
+
112
+
It returns a list of `IMicroflowParameterObject`, which includes:
113
+
114
+
* Name
115
+
*`IQualifiedName` identifier
116
+
* Description
117
+
*`DataType`
103
118
104
-
The `GetParameters` method enables retrieving all the parameters that are inputs into a microflow. It returns a list of `IMicroflowParameterObject`, which is composed of its name, its `IQualifiedName` identifier, a description, and its `DataType`. Any parameters passed into the microflow will be returned here together with their type.
The `IsVariableNameInUse` method can check if the microflow already contains a variable with the name provided. This can be called before adding a new activity to the flow whose output variable name can overlap with existing variables. An example is as follows:
134
+
Use the `IsVariableNameInUse` method to check if the microflow already contains a variable with the name provided. This can be called before adding a new activity to the flow whose output variable name can overlap with existing variables.
0 commit comments