How to launch a nanoflow from the HTMLSnippet with a parameter - Mendix Forum

How to launch a nanoflow from the HTMLSnippet with a parameter

0

Hi,

I have a Page with a non persistable data source Temp.

The entity Temp have a attribute “String”

I would like to launch a Nanoflow inside this widget and put Temp.String as  a parameter to the nanoflow.

 

 

data.callNanoflow({
    nanoflow: this.propertyWithNanoflow,
    origin: this.mxform,
    context: this.mxcontext,
    callback: function(result) {
        alert("Nanoflow completed with result " + result);
    },
    error: function(error) {
        alert(error.message);
    }
});

 

I found this on the apidocs but how i put Temp.String to the nanoflow?

 

Thanks Stephan  

asked
3 answers
0

I found now a Solution with a microflow.

  1.  I create a nonpersitable entity with 2 attributes (TempGuid, String) 

 

  1. This Temp Entity i put to a dataview on my page where the javascript snippet is.

 

  1. On the JavaScript Snippet i lauch a microflow with the Temp Object as Parameter

 

mx.data.action({
    params:{
        applyto: "selection",
        actionname: "ForgotPasswordCustomization.LaunchTenantHomePage",
        guids: [ '${tempGUID}' ] 
    },
    origin: this.mxform,
    callback: function(obj) {
        //Object not required
    },
    error: function(error) {    
        alert(error.message);        
    },
    onValidation: function(validations) {
        alert("There were " + validation.length + " validation errors");
    }
});

 

  1. On the microflow i can now do what i need to do.

 

 

Thanks Stephan

 

 

 

answered
0

Hi Ivo

Thanks for your support.

I have some issues with the code.

  1. I have configured the datasource with the variable customdomain

 

 

 

Where and how i set the nanoflow i want to execute with the parameter $customdomain?

Thanks for any help!

Stephan  

answered
0

Hi Stephan,

Doing this from within a HTML snippet is a bit cumbersome. 

My advise:

Option 1: use a JavaScript action if possible

Option 2: use the JavaScript snippet widget, in that widget the dataview context entity can be used in the JS code as a variable which is stated in the widget

Option 3: use the HTML snippet. It is hard to get the dataview entity the snippet is encapsulated in. The dojo framework has a function called dijit.getEnclosingWidget. THis can be used here, but needs some Dojo expertise.

answered