0

Hello everyone, I'm currently working on a scenario where users input an equation consisting of attributes (let's call them A1, A2, and A3), and then the system fetches corresponding values from text fields as shown below. For example, if the equation is something like A1+A2*A3, and the values provided by the user are A1 = 4, A2 = 5, and A3 = 6, how can I dynamically translate this equation (A1+A2*A3) into a format that converts it into a string, in this case, the output should be 4 + 5 * 6 I'm looking for a solution that efficiently handles such dynamic equations and their associated values from user input.

asked

Yogeshwar Polawar

3 answers

3

Hi Yogeshwar,

For this you can create a string variable, and in the part where we are calculating the formula,

you can change the string variable, and append the exact values along with the signs.

Let me know, if you have any issues,

Hope it helps!

answered

Rishabh Shandilya

1

Hi Yogeshwar,

As per my understanding you have 1 or more entity having some attribute/columns in that, now user is writing generic statement like:- Column1+Column2*Column3.

So in this case we can hold this in string variable/entity attribute and using hard code logic we need to check for all possible attributes user is allowed to used and replace their value in this string.

Means for an example Column1=2, Column2=5 and Column3=3

then variable Equation = Column1+Column2*Column3

Mendix microflow definition:

Node 1:- find Column1 in string Equation if found then replace with it's value so the result will be 2+Column2*Column3

Node 2:- find Column1 in string Equation if found then replace with it's value so the result will be 2+5*Column3

Node 3:- find Column1 in string Equation if found then replace with it's value so the result will be 2+5+3.

Now using java action to evaluate this string and here is the support link for related java code: https://stackoverflow.com/questions/3422673/how-to-evaluate-a-math-expression-given-in-string-form

Let me know, if you have any issues,

Hope it helps!

answered

Aakash Verma

1

Change the type of the input parameter from String to Object, and select the object that is the context object for your button (in other words, that 'surrounds' you button and is available on the page).

Using this object you can check the value of the attribute that is part of the object you pass to the microflow.

Also, you can check out the Mendix Learning modules: they contain these topics and make sure you don;t get stuck all the time while taking your first steps in Mendix :)

answered

parvathi peraka