Call a Microflow from javascript

2
As it's currently not possible to directly pass a string parameter value from javascript to a Microflow, I would like to achieve my goal using a different approach. The idea is to create a non-persistent object in javascript and pass that one as a parameter to the microflow. The microflow is triggered, but the parameter object keeps being empty :(. Can someone point me in the direction of what is lacking or wrong in the code beneath? function do_something() { var myinput = document.getElementById("my_input"); mx.data.create({ entity: "MyModule.myObject", callback: function(object){ alert(object + ':' + myinput.value); object.set('myString',myinput.value) mx.processor.xasAction({ error: function() { logger.error(this.id + "error: error while executing search"); }, actionname: "MyModule.MyMF", guids: [object.getGUID()] }); } }); }
asked
2 answers
0

Maybe you have to save and commit the object before passing it.

answered
0

I am trying to do the same, The micro flow is triggered, but the parameter object keeps being empty, I tried to save and commit as suggested but didn’t worked. can anyone help?


Method 1: 

function passStringToMicroflow(stringValue) {
    mx.data.create({
        entity: "Signature.ImageNP",
        callback: function (obj) {
            obj.set('ImageNPname', stringValue);
            object.set('ImageNPname', stringValue);
            object.save();
    
            mx.data.action({
                params: {
                    applyto: "selection",
                    actionname: "Signature.signMF",
                    guids: [obj.getGuid()],
                },
            });
            obj.save();
            mx.data.commit(obj);
        }
    });

}

Method 2:

function passStringToMicroflow(stringValue) {

    mx.data.create({
        entity: "Signature.ImageNP",
        callback: function (object) {
            alert(object + ':' + stringValue);
            object.set('ImageNPname', stringValue);
            object.save();
            mx.data.commit(object);
            mx.processor.xasAction({
                error: function () {
                    logger.error(this.id + "error: error while executing search");
                },
                actionname: "Signature.signMF",
                guids: [object.getGUID()]
            });
        }
    });
}
 

answered