Hi Martin,
Not exactly ideal, but you can get your parent widget in javascript by calling something like
dijit.getEnclosingWidget(widget.domNode.parentNode);
Then you could retrieve that widgets contextObject. Its just an idea
-Andrej
Hi Martin,
I like Andrej's answer, never knew you could do that .
Another option, depending on the complexity of your widget is to use references. Create a main non persistable DummyContext in which the widget is placed then setting references to other entities to which you need access from your widget.
The Drag Drop Support widget is a great example.
Hi Martijn,
In a widget, you can also access the stored "context path" from your current context object back to the highest-level context on the page:
// where `this` is the widget instance
this.mxcontext._contextStore;
/*
{
"TestSuite.TopLevelContextEntity":"{guid}",
"TestSuite.NextLevelContextEntity": "{guid}",
...
"TestSuite.CurrentContextEntity": "{guid}"
}
*/
This is especially useful if you're just trying to get the guid of the next level up (likely associated) object. Keep in mind though, that you can probably just do this retrieve in the microflow as well.
Hi Martijn,
It is not possible to select a microflow with 2 parameters for a custom widget. As workaround you could use a string parameter.
Calling a microflow, you could use the the parameter and context to provide the 2 objects
mx.data.action({
params: {
applyto: "selection"
actionname: "MyFirstModule.GetFavoriteFood",
guids: [ "281530811285515"]
},
origin: this.mxform,
context: this.mxcontext,
callback: function(obj) {},
error: function(error) { }
});
in case you dont want use the context of the form but an other object, you can create a new context
var c = new mendix/lib/MxContext();
context.setContext("MyFirstModule.Entity", "12345");
Sheers,
Andries
The answers here provide some workaround but we can all agree they are just workarounds.
If you want to see this implemented in the platform itself upvote the idea:
https://forum.mendix.com/link/ideas/766