Passing parameter to microflow from custom widget

0
Ciao! I developed a custom widget using Typescript and React, representing data on a sunburst chart. I now have a request to allow execution of microflow as an on click event. I was able to configure the onclick event using action property in my xml definition file and launch the microflow using this code: if(this.props.handleClick?.canExecute && !this.props.handleClick.isExecuting){ this.props.handleClick.execute(); } My chart is rendered starting from a list of objects but I would need to pass as parameter to the microflow the clicked object from that list. execute above doesn't accept parameters. Is it possible to achieve this someway? If yes can someone explain how can I achieve this?
asked
1 answers
0

Hi Angelo,

 

Not sure if there's an easier/better way to do this, but the way I do it is:

  • Make sure the object that you need to be available to the microflow in in scope of the widget: eg. Have a dataview fetch that object which then wraps the widget inside.
  • Add the attribute(s) that you need to send to the microflow in the xml file:
 <property key="AttributeExample" type="attribute" >
                <caption>Attribute Example (String)</caption>
                <description>Description.</description>
                <attributeTypes>
                    <attributeType name="String"/>
                </attributeTypes>
</property>
  • On the widget, set the value of this attribute before calling the microflow. That's it!
if (exampleAction&& exampleAction.canExecute && !exampleAction.isExecuting) {
                    if (AttributeExample && AttributeExample.status === "available")
                        AttributeExample.setValue(value);
                    exampleAction.execute();
            }
        });
  • The microflow must contain the object (with the AttributeExample attribute) as input.

Hope this helps,

João

answered