Creating on-change microflow attribute in custom widget

3
I've succesfully create my first custom widget. Now i want to add an onchange microflow attribute to the widget. Calling a microflow is explained in the documentation , but how can I trigger the microflow during onchange?
asked
5 answers
2

You can receive changes by connecting a function to the 'onchange' event.

this.connect(this.myNode, "onchange", dojo.hitch(this, this.EventOnChange)));

In case of a textbox this sends changes for every keypress and unless you want to execute the microflow on each on of those, it is better to use the 'onblur' event.

this.connect(this.myNode, "onblur", dojo.hitch(this, this.eventInputBlur)));
this.connect(this.myNode, "onfocus", dojo.hitch(this, this.eventInputFocus)));

For more information about events you can check out this basic article at w3schools or this article about the same events in dojo.

Don't forget to upload it to the App Store if you want others to be able to use it. This is also a great way to get a review of your code and might help you write better widgets or modules. We make sure that every time we need to decline an App, we send an extensive e-mail explaining what needs be improved and how, both about your code as well as your documentation/xml. So don't be afraid to upload it when you feel it is ready to be critiqued ;).

answered
2

The post data you posted does NOT belong to the mx.processor.xasAction invocation, since it is a 'change' action and not an 'executeation'. So the data you are looking at is triggered by either another widget or by a change performed by you, but it is not triggered by the onChange function.

This is what mx.process.xasaction POST looks like:

{"action":"executeaction","params":{"entity":"MyFirstModule.TreeItem","xpath":"//MyFirstModule.TreeItem","constraints":"[id=281492156579847]","applyto":"selectionset","sort":[["Caption","asc"]],"gridid":"7741","actionname":"MyFirstModule.NewItem"},"context":[281492156579847]}

A problem might be that your function is named onChange, i would not be surprised if that function is called automatically by the client, so you should use a less general name.

answered
1

So far, we've been able to trigger a microflow while during onchange. We've tried to show a message with the attribute name. The message triggers but we've not been able to pass the name of a attribute in a show message activity: Date has been changed for organization {1}. {1} is connected to $organization/name. " Date has been changed for organization null" is what we get. I think there is some issue with the context.

answered
1

You should be able to see in firebug which guids are passed along with the action. You need to pass them explicitly when invoking the action, for example (myguid should be a long value):

mx.processor.xasAction({ 
//skipped properties
 applyto     : 'selection',
 guids       : [myguid]
});
answered
1

I've used your example to change the onchange function:

onChange:function(){
if(this.onchangeMicroflow){
mx.processor.xasAction({
    error       : function() {
        logger.error(this.id + "error: XAS error executing microflow");
    },
    actionname  : this.onchangeMicroflow,
    guids       : [this.dataobject.getGUID()]
});}
},

Unfortunately, this is not working. Results in Firebug #change post:

JSON
action
    "change"

context
    []

params
    Object { 281487861612546=Object}
Bron
{"action":"change","params":{"281487861612546":{"date_localized":1281657600000}},"context":[]}

Results in Firebug #change antwoord:

{}

answered