Mendix model api error in modeler when using microflowCallParameterMapping

0
  I used the model api to generate code for creating a microflow. The code included: var microflowCallParameterMapping1 = microflows.MicroflowCallParameterMapping.create(model); microflowCallParameterMapping1.argument = "'CodeGenerator.NavigateToWelcome'"; var microflowCall2 = microflows.MicroflowCall.create(model); microflowCall2.microflow = model.findMicroflowByQualifiedName("Component_PageView.ChangeCurrentPage"); microflowCall2.parameterMappings.push(microflowCallParameterMapping1); The code run's, but after updating in de Modeler I get the error: System.NullReferenceException: Object reference not set to an instance of an object. at Mendix.Modeler.Microflows.MicroflowCallParameterMappingBase`4.CollectUsages(UsagesInfo usages) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Microflows\Common\MicroflowCallParameterMapping.cs:line 61 at Mendix.Modeler.Common.Usages.<>c__DisplayClass1_0.<Collect>b__0(IHasUsages usageProvider) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Common\Usages\Usages.cs:line 38 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 87 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Storage.Operations.TypeWalk.ForEachObjectDo(IStorageObject root, Func`2 work, Boolean skipExcludedObjects) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\TypeWalk.cs:line 92 at Mendix.Modeler.Common.Usages.Collect(IStorageObject obj) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Common\Usages\Usages.cs:line 35 at Mendix.Modeler.Common.Problems.Check(IProject project) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Common\Problems\Problems.cs:line 68 at Mendix.Modeler.Common.BackgroundChecker.DoCheck() in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Common\Problems\BackgroundChecker.cs:line 116 at Mendix.Modeler.Common.BackgroundChecker.Check() in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Common\Problems\BackgroundChecker.cs:line 86 And after this the project is unable to be used. Full project is available at https://github.com/JAM-IT-NL/MendixModelAutomater Anybody now a fix?
asked
1 answers
2

The problem is that you are not setting the name of the parameter for which you specify an argument. Normally, this would be done by setting the property 'parameter' of the microflowCallParameterMapping1 to the relevant parameter object of the microflow you're calling. However, there is currently a limitation in the Model SDK that we have not solved yet, which makes this impossible at this time.

Fortunately, there is a workaround. As the parameter reference is a String value (the fully qualified name of the parameter) under the hood, we can set it as follows:

(microflowCallParameterMapping1 as any)["__parameter"].updateWithRawValue("Component_PageView.ChangeCurrentPage.ParameterName");

where `ParameterName` should be replaced by the actual name of the parameter.

Note: this workaround only works in Model SDK v4.0.0 and greater.

answered