How do I schedule an event that triggers a microflow that has to apply security?
2
It is not allowed to have a schedule event trigger a microflow that applies entity access. But my scheduled event needs to check an inbox to automatically import the emails and process them as e.g. tasks. In my multi-tennant environment I need to apply entity access. The account used as inbound email address needs to be "tennant" specific and the processing needs to be specific for the environment of that "tennant" (e.g. specific default status should be used). How can I accomplish this? Update: To clarify a bit further: I need to apply entity access because security has been set up such that every "tennant" has an identifier. That identifier is related to every item created by that "tennant". And access to every item is entity access/xpath constrained by the identifier (identifier of item = identifier of user). When processing mails (e.g. as task) I need to retrieve the default values configured for that "tennant" for that task. I want to reuse the microflows I have for that which, in line with set up of multi-tennancy, apply entity access. I could indeed duplicate all of them and constrain on identifier in the microflows, but that does not have my preference (maintainability, etc.). So, is there a way to reuse those microflows when calling them via java? If so, how exactly? Should be something like: Import emails Call java with the email sender as input From java call the microflows with apply security and the context of the sender identifier.
asked
Frans Verschoor (FraternIT)
2 answers
3
If you like hacking java actions onto the mendix api, I think it could be possible to abuse the core api to create a new user session (can this be done without knowing someone's password?) and call a microflow using the context object of the internally created session. This way you get the currentuser token for free. :)
answered
Hans van Kranenburg
3
A scheduled event doesn't have a user role so you can't apply entity access. But you can just use xpath constraints to use the right objects right? Or do you mean you want to re-use the same microflows? I don't think that is possible unless you run them from a Java action.
Please check the documentation on how to run microflows from a Java action.
Keep in mind you can't use the current user token in microflows that run as a scheduled event either.