Had an interesting question to day from Raymond asking how to cast variable in Studio. He wants to add two double fields and put the result in another field using Content Automation. While writing your operation parameter, you might not know it but you are actually using the MVEL expression language.
MVEL is a powerful expression language for Java-based applications. It provides a plethora of features and is suited for everything from the smallest property binding and extraction, to full blown scripts. For more information, jump right to the Getting Started Guide.
Again, one of the difficulties while using Nuxeo Studio is to know which EL you can use and when. Bertrand recently wrote a very good explanation for this topic. You have to read this, seriously.
Back to the question now, Raymond was doing the following:
@{Document["calcul1:field1"]} + @{Document["calcul1:field2"]}
This will be evaluated as a String, resulting in something like “1.0+2.0″. While what we wanted was 3.0. To have a double you need to write this:
@{Document["calcul1:field1"] + Document["calcul1:field2"]}
You can do some fairly advanced things using MVEL like handling List, Arrays, use conditional expressions etc.. It’s a very powerful tool!
The post [Q&A Friday] How to add two doubles with Content Automation appeared first on Nuxeo Blogs.