Ability to create internal functions to be used inside blocks (i.e. substring) - Mendix Forum

Ability to create internal functions to be used inside blocks (i.e. substring)

0

Example case: I have an object with 40 attributes. I am filling its contents with a text string. I need to transform the text by using a (java) function of most of the attributes.

I know you can create java actions to do specific tasks, however, you need to call them as a separate block and then use its result. So in the example case I need to create 40 java action calls to html encode the text of each attribute and the use each result in the change object call…

So I wondered: wouldn’t it be nice if we could somehow inject our custom functions into the internal Mendix function list that’s accessible from within those change attribute blocks (i.e. substring, replaceAll, toString, etc.). 

Like the option to expose a java action as a microflow action, you could tick a box to expose it as a function and that function would also be accessible from within Mendix.

Or a simple config file inside the resource folder that allows you to define and expand the current function list.

Another implementation could be to allow microflows to be used in that same way. At the moment, you can create a ‘rule’ microflow that you can use in expressions blocks. In a similar way you could create a microflow function that might do something with the text so it can be called from within the change object blocks.

So let’s take the simple microflow htmlEncodeString in the module ModuleName:

 

You’ll have the option to Expose it as a function. If you tick ‘Yes’, it will appear in the internal function list and it can be used just like a function:

In this case, I wouldn’t have to create 40 microflow blocks that transform my text (so I can use their result) but I can create one microflow that I can reuse inside the result fields.

asked
0 answers