Skip to content

Commit 33dc5f8

Browse files
committed
Review
1 parent 51f6a01 commit 33dc5f8

1 file changed

Lines changed: 26 additions & 19 deletions

File tree

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/create-microflows-calculations.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ Like the multiplication microflow example above, the strings `addition1` and `ad
194194

195195
{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/addition-microflow.png" >}}
196196

197-
## Create Microflow Activities That Call Java Actions
197+
## Create Call Activities
198198

199-
Once a microflow is created, you need to add a call activity (`IActionActivity`). In the example, you have a method called `CreatMicroflowCallActivity` that can be used by both your multiplication and addition microflows.
199+
After you create a microflow, you need to add a call activity (`IActionActivity`) so it can be used by other microflows. In the example, there is a method called `CreatMicroflowCallActivity` that works for both your multiplication and addition microflows.
200200

201-
There are a few prerequisites that you must complete before a microflow can be called by another microflow. This method can be broken down into parts:
201+
Before one microflow can call another, you need to complete some prerequisites. This method can be broken down into parts:
202202

203203
```csharp
204204
var microflowCallActivity = currentApp.Create<IActionActivity>();
@@ -210,17 +210,15 @@ microflowCallActivity.Action = microflowCallAction;
210210
microflowCallAction.OutputVariableName = outputVariableName;
211211
```
212212

213-
In order to create `IActionActivity`, `IMicroflowCallAction` must also be created, and set as the `Action` property of the `IActionActivity`.
213+
1. Create `IActionActivity`. This is the activity that will call another microflow.
214+
2. Create `IMicroflowCallAction` and set it as the `Action` property of the `IActionActivity`.
215+
3. Create `IMicroflowCall` and set as the `MicroflowCall` property of the `IMicroflowCallAction`.
216+
4. Set `QualifiedName` of the microflow you want to call as the `Microflow` property of the `MicroflowCall` object.
217+
5. Set the `OutputVariableName` on so the calling microflow can use the result returned by the called microflow.
214218

215-
Then, for `IMicroflowCallAction`, `IMicroflowCall` must also be created and set as the `MicroflowCall` property of the `IMicroflowCallAction`.
219+
## Passing Parameters to Called Microflows
216220

217-
Next, `QualifiedName` of the microflow, which is to be called by this activity, must be set as the `Microflow` property of the `MicroflowCall` object.
218-
219-
Finally, you can set `OutputVariableName` on `IActionActivity`, which is what the calling microflow will read from the called microflow.
220-
221-
## Passing Parameters
222-
223-
It is also possible to pass a set of parameters to the action activity, which will be the inputs for the called microflow. This set of parameters is a simple `Tuple` of a name and an expression. In the example, these parameters are the two integers for the multiplication microflow and the two decimals for the addition microflow.
221+
You can pass parameters to the action activity, which will be the input for the called microflow. This set of parameters is a `Tuple` of a name and an expression. In the example, these parameters are the two integers for the multiplication microflow and the two decimals for the addition microflow.
224222

225223
```csharp
226224
foreach (var (parameterName, expression) in parameters)
@@ -233,7 +231,7 @@ foreach (var (parameterName, expression) in parameters)
233231
}
234232
```
235233

236-
The method in its entirety is below and can be pasted into your `CalculationsMicroflowCreator` class.
234+
Paste the complete into your `CalculationsMicroflowCreator` class.
237235

238236
```csharp
239237
void CreateMicroflowCallActivity(IModel currentApp,
@@ -262,7 +260,7 @@ void CreateMicroflowCallActivity(IModel currentApp,
262260
}
263261
```
264262

265-
To create a call activity for your multiplication and addition microflows, you can use something like the code below. As you can see, the parameter names for the activity match the parameter name from the microflow and their values are also passed in for integers and decimals.
263+
To create a call activity for your multiplication and addition microflows, use code similar to the following:
266264

267265
```csharp
268266
CreateMicroflowCallActivity(currentApp, callingMicroflow, mathMicroflow,
@@ -276,15 +274,24 @@ CreateMicroflowCallActivity(currentApp, callingMicroflow, additionMicroflow,
276274
("addition2", "2.2"));
277275
```
278276

279-
The calling microflow looks as follows:
277+
As you can see, the parameter names for the activity match the parameter name from the microflow. Their values are passed in for integers and decimals.
278+
279+
The calling microflow looks as seen below:
280280

281281
{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/main-microflow.png" >}}
282282

283283
## Java Actions
284284

285-
Outside of this calculation examples, you might want to create a microflow activity that calls a Java action file. See below for how to add an activity, and action and a call to the microflow to achieve that. Same as in the previous examples, you have to do this inside a transaction (`IModel.StartTransaction`).
285+
You can create a microflow activity that calls a Java Action. This must be done inside a transaction (`IModel.StartTransaction`).
286286

287-
First, create an `IActionActivity`, just like the calculation example above, but then, its `Action` property will have the type `IJavaActionCallAction` instead of `IMicroflowCallAction`. This `IJavaActionCallAction` will need to know which `IJavaAction` is linked to. You can achieve this by setting the property `JavaAction` on the `IJavaActionCallAction` object to the `IQualifiedName` of the `IJavaAction`. If you are creating a brand new `IJavaAction`, it is important to add it to the module before accessing its `IQualifiedName`. If you have `IJavaAction` already, and you want to set up a call for that one, find it in the app and pass along its `IQualifiedName`. See below for an example.
287+
1. Start a transaction using `IModel.StartTransaction`.
288+
2. Create an `IActionActivity`.
289+
3. Set the `Action` property to `IJavaActionCallAction`.
290+
4. Link `IJavaActionCallAction` to the `IJavaAction`.
291+
5. Set the `JavaAction` property to the `IQualifiedName` of the `IJavaAction`.
292+
6. For `IJavaAction`:
293+
1. For a new `IJavaAction` – add it to the module. Only access its `IQualifiedName` after it has been added.
294+
2. For an existing `IJavaAction` – find it in the app and pass its `IQualifiedName` to the `IJavaAction` property of `IJavaActionCallAction`.
288295

289296
```csharp
290297
public void CreateMicroflowAndJavaAction(IModule module, IModel currentApp)
@@ -310,7 +317,7 @@ public void CreateMicroflowAndJavaAction(IModule module, IModel currentApp)
310317
}
311318
```
312319

313-
If you already have a Java action file that you previously created, simply pass its `IQualifiedName` to the Java action. You will need to query the model in order to retrieve the actual object. You can do so as follows:
320+
If you already previously created a Java action file, you can pass its `IQualifiedName` to the Java action. You will need to query the model to retrieve the actual object. You can do so as follows:
314321

315322
```csharp
316323
IQualifiedName FindJavaAction(string name, IModule module)
@@ -320,4 +327,4 @@ IQualifiedName FindJavaAction(string name, IModule module)
320327
}
321328
```
322329

323-
Download the [whole code](https://github.com/mendix/ExtensionAPI-Samples) to see the way it works in its entirety.
330+
Download the [whole code](https://github.com/mendix/ExtensionAPI-Samples) to see the full implementation.

0 commit comments

Comments
 (0)