How to use executeUnverifiedMicroflowAsUser_1 with a string-parameter?

I have several microflows all having one parameter of type string. And I need to call one of them by name. I can do so using executeUnverifiedMicroflowAsUser_1, but that requires the microflows to have input parameters of type object. Is it possible to use executeUnverifiedMicroflowAsUser_1 with a string-parameter instead of the Object that you now have to pass? The executeUnverifiedMicroflowAsUser_1 to me looks to be built in a way that it does not allow for any other parameter type that ‘Object’ As soon as I assign the Type to ‘String’, and in the microflow that gets called (as per value I pass in microflowName) I change the parameter form an object to a string, then upon running the app locally I get this failure: [javac] C:\Users\timva\Documents\Tieka Mx Services-main\javasource\communitycommons\ error: incompatible types: Map<String,String> cannot be converted to Map<String,Object>   With a little tweaking in the java-code I have attemped to have the java-code accept the string, but the .withParams also does not except <String, String>. public static Object executeMicroflowAsUser(IContext context, String microflowName, String username, Boolean sudoContext, Object... args) throws Exception { if (context == null) { throw new Exception("Assertion: No context provided"); } if (microflowName == null || microflowName.isEmpty()) { throw new Exception("Assertion: No context provided"); } if (!Core.getMicroflowNames().contains(microflowName)) { throw new Exception("Assertion: microflow not found: " + microflowName); } if (args.length % 2 != 0) { throw new Exception("Assertion: odd number of dynamic arguments provided, please name every argument: " + args.length); } Map<String, Object> params = new LinkedHashMap<String, Object>(); for (int i = 0; i < args.length; i += 2) { if (args[i] != null) { params.put(args[i].toString(), args[i + 1]); } } IContext c = getContextFor(context, username, sudoContext); return Core.microflowCall(microflowName).withParams(params).execute(c); }   Is there way to call a microflow by name and pass a string?   *Editted* This was the result: /** * Calling the microflow that executes the actual service as defined by the ServiceOwner */ public class MyExecuteMicroflowAsUser_1string extends CustomJavaAction<java.lang.String> { private java.lang.String microflow; private java.lang.String username; private java.lang.Boolean sudoContext; private java.lang.String arg1name; private java.lang.String arg1value; public MyExecuteMicroflowAsUser_1string (IContext context, java.lang.String microflow, java.lang.String username, java.lang.Boolean sudoContext, java.lang.String arg1name, java.lang.String arg1value) { super(context); this.microflow = microflow; this.username = username; this.sudoContext = sudoContext; this.arg1name = arg1name; this.arg1value = arg1value; } @java.lang.Override public java.lang.String executeAction() throws Exception { // BEGIN USER CODE Object res = com.mendix.core.Core.microflowCall(microflow) .inTransaction(true) .withParam(arg1name, arg1value) .execute(this.getContext()); return res == null ? null : res.toString(); // END USER CODE } /** * Returns a string representation of this action */ @java.lang.Override public java.lang.String toString() { return "MyExecuteMicroflowAsUser_1string"; } // BEGIN EXTRA CODE // END EXTRA CODE }  
1 answers

Hi Tim, 

It's possible with some tweaking like you already did. Check out the post by Robert Price for detailed steps to get the right input params. 

If the input parameter(s) of your microflows differ in name, use the Core.getInputParameters first in your java action to get the right name in the input variable to put in your param mapping.