Hi K Divya,
You can use this code in the SDK to create a microflow:
const newMicroflow = microflows.Microflow.createIn(mfModule); newMicroflow.name = "MyNewMicroflow";
This code is for the mfModule, so you will need to change some specifics. You were probably looking for the CreateIn function, which you can find here: https://apidocs.rnd.mendix.com/modelsdk/latest/classes/microflows.microflow.html
Also, some additional documentation: https://docs.mendix.com/apidocs-mxsdk/mxsdk/microflows-metamodel/#22-retrieving-objects
So if you use the JavaScriptSerializer.serializeToJs() on an existing project, you will get the example code to create a microflow. This is also the way Mendix recommends you do it.
Follow the example Mendix Forum - Question Details to see how to use JavaScriptSerializer.serializeToJs().
I've used it on one of my projects and here was the output for 1 microflow.
(function (unit, model) {
/* * JavaScript code generated by mendixmodelsdk.sdk.extras.JavaScriptSerializer * from unit with id "" of type Microflows$Microflow * in working copy "" * on 14-11-2023. */
var startEvent1 = microflows.StartEvent.create(model); startEvent1.relativeMiddlePoint = {"x":145,"y":190}; startEvent1.size = {"width":20,"height":20};
var endEvent1 = microflows.EndEvent.create(model); endEvent1.relativeMiddlePoint = {"x":700,"y":190}; endEvent1.size = {"width":20,"height":20}; endEvent1.returnValue = "$MyFirstEntity";
var constantRange1 = microflows.ConstantRange.create(model);
var sortItemList1 = microflows.SortItemList.create(model);
var databaseRetrieveSource1 = microflows.DatabaseRetrieveSource.create(model); databaseRetrieveSource1.entity = model.findEntityByQualifiedName("MyFirstModule.MyFirstEntity"); databaseRetrieveSource1.range = constantRange1; // Note: for this property a default value is defined. databaseRetrieveSource1.sortItemList = sortItemList1; // Note: for this property a default value is defined.
var retrieveAction1 = microflows.RetrieveAction.create(model); retrieveAction1.retrieveSource = databaseRetrieveSource1; // Note: for this property a default value is defined. retrieveAction1.outputVariableName = "MyFirstEntity";
var actionActivity1 = microflows.ActionActivity.create(model); actionActivity1.relativeMiddlePoint = {"x":355,"y":190}; actionActivity1.size = {"width":120,"height":60}; actionActivity1.action = retrieveAction1;
var expressionSplitCondition1 = microflows.ExpressionSplitCondition.create(model); expressionSplitCondition1.expression = "1 = 1";
var exclusiveSplit1 = microflows.ExclusiveSplit.create(model); exclusiveSplit1.relativeMiddlePoint = {"x":530,"y":190}; exclusiveSplit1.size = {"width":90,"height":60}; exclusiveSplit1.splitCondition = expressionSplitCondition1; // Note: for this property a default value is defined. exclusiveSplit1.caption = "ConditionShape";
var endEvent2 = microflows.EndEvent.create(model); endEvent2.relativeMiddlePoint = {"x":530,"y":315}; endEvent2.size = {"width":20,"height":20}; endEvent2.returnValue = "$MyFirstEntity";
var objectType1 = datatypes.ObjectType.create(model); objectType1.entity = model.findEntityByQualifiedName("MyFirstModule.MyFirstEntity");
var parameterMyFirstEntity1 = microflows.MicroflowParameterObject.create(model); parameterMyFirstEntity1.relativeMiddlePoint = {"x":145,"y":70}; parameterMyFirstEntity1.size = {"width":30,"height":30}; parameterMyFirstEntity1.name = "parameterMyFirstEntity"; parameterMyFirstEntity1.variableType = objectType1; // Note: for this property a default value is defined. parameterMyFirstEntity1.hasVariableNameBeenChanged = true;
var microflowObjectCollection1 = microflows.MicroflowObjectCollection.create(model); microflowObjectCollection1.objects.push(startEvent1); microflowObjectCollection1.objects.push(endEvent1); microflowObjectCollection1.objects.push(actionActivity1); microflowObjectCollection1.objects.push(exclusiveSplit1); microflowObjectCollection1.objects.push(endEvent2); microflowObjectCollection1.objects.push(parameterMyFirstEntity1);
var noCase1 = microflows.NoCase.create(model);
var sequenceFlow1 = microflows.SequenceFlow.create(model); sequenceFlow1.originConnectionIndex = 1; sequenceFlow1.destinationConnectionIndex = 3; sequenceFlow1.originBezierVector = {"width":0,"height":0}; sequenceFlow1.destinationBezierVector = {"width":-30,"height":0}; sequenceFlow1.caseValue = noCase1; // Note: for this property a default value is defined.
var noCase2 = microflows.NoCase.create(model);
var sequenceFlow2 = microflows.SequenceFlow.create(model); sequenceFlow2.originConnectionIndex = 1; sequenceFlow2.destinationConnectionIndex = 3; sequenceFlow2.originBezierVector = {"width":30,"height":0}; sequenceFlow2.destinationBezierVector = {"width":-15,"height":0}; sequenceFlow2.caseValue = noCase2; // Note: for this property a default value is defined.
var enumerationCase1 = microflows.EnumerationCase.create(model); enumerationCase1.value = "true";
var sequenceFlow3 = microflows.SequenceFlow.create(model); sequenceFlow3.originConnectionIndex = 1; sequenceFlow3.destinationConnectionIndex = 3; sequenceFlow3.originBezierVector = {"width":15,"height":0}; sequenceFlow3.destinationBezierVector = {"width":-15,"height":0}; sequenceFlow3.caseValue = enumerationCase1; // Note: for this property a default value is defined.
var enumerationCase2 = microflows.EnumerationCase.create(model); enumerationCase2.value = "false";
var sequenceFlow4 = microflows.SequenceFlow.create(model); sequenceFlow4.originConnectionIndex = 2; sequenceFlow4.originBezierVector = {"width":0,"height":15}; sequenceFlow4.destinationBezierVector = {"width":0,"height":-15}; sequenceFlow4.caseValue = enumerationCase2; // Note: for this property a default value is defined.
var listType1 = datatypes.ListType.create(model); listType1.entity = model.findEntityByQualifiedName("MyFirstModule.MyFirstEntity");
var text1 = texts.Text.create(model);
var dS_MyFirstEntity_Get1 = microflows.Microflow.createIn(unit); dS_MyFirstEntity_Get1.name = "DS_MyFirstEntity_Get"; dS_MyFirstEntity_Get1.objectCollection = microflowObjectCollection1; // Note: for this property a default value is defined. dS_MyFirstEntity_Get1.flows.push(sequenceFlow1); dS_MyFirstEntity_Get1.flows.push(sequenceFlow2); dS_MyFirstEntity_Get1.flows.push(sequenceFlow3); dS_MyFirstEntity_Get1.flows.push(sequenceFlow4); dS_MyFirstEntity_Get1.microflowReturnType = listType1; dS_MyFirstEntity_Get1.concurrencyErrorMessage = text1; // Note: for this property a default value is defined.
sequenceFlow1.origin = startEvent1; sequenceFlow1.destination = actionActivity1;
sequenceFlow2.origin = actionActivity1; sequenceFlow2.destination = exclusiveSplit1;
sequenceFlow3.origin = exclusiveSplit1; sequenceFlow3.destination = endEvent1;
sequenceFlow4.origin = exclusiveSplit1; sequenceFlow4.destination = endEvent2;
})
I would suggest you follow these excellent blog posts from Adrian Preston:
https://www.mendix.com/blog/a-mendix-sdk-primer-part-1/
https://www.mendix.com/blog/a-mendix-sdk-primer-part-2/
Code samples are also included. So will give you a lot of guidance.