Accepted Solution

MVEL calculation issue


I need to do some calculations in a Workflow and the result is not as expected. For troubleshooting purposes I created Workflow return paramaters that do the same calculation. The return parameters print all variables that I use for the calculation, the actual calculation as well as the same calculation with fixed values instead of variables. From the return parameters I can see that all variables have the expected value, however the calculation return an incorrect value (while the same calculation with fixed values give the correct result). Does anybody have an idea what's going on?

This is the definition of the return parameters:

And these are the return parameters after preview:



Re: MVEL calculation issue

It looks like it is treating your value from size_mb as a STRING and not INT.  I had an issue like that before and fixed it by declaring the value as an (int) (parameter) + value.  This worked very well prior to upgrade to 1.1 but afterwards I found that I didn't have to do that for the specific reason I was implementing it.  What does your Define or Function look like? 

Re: MVEL calculation issue

Hi Hendrik,

Indeed interesting on MVEL side.

If you look closely (And you probably did) you can see that the result is a string concatenation of the size_mb with the result of the subtraction action.

MVEL somehow decides to concatenate the size_mb with the subtraction result and that's what you see as a result.

Why does it subtracts in the first place? I guess that is due to the fact there is no string subtraction so MVEL figures these are numbers.

What I can offer you to try is to make sure MVEL understands these are integers by making the "(int)" denomination before the "vol_existingVolume.size_mb".

I will compile such a use-case and publish the results here.



Re: MVEL calculation issue

Thanks guys, you're right. Manually casting the size_mb to int fixes it. Should've though about that myself... D'oh!

The volume object is from a finder, not sure why it treats these as string, but since I know how to fix it that's not a problem.

..- Hendrik

Re: MVEL calculation issue

What version of WFA are you using?  WFA 1.1 or an earlier version?



Re: MVEL calculation issue

I'm using 1.1. Anyway, I can easily solve this as suggested by others above...

..- Hendrik