Cool New Variable Substitution Features in Flux 7.11!
Yesterday, we released the latest version of Flux, 7.11. One of my favorite new features is the expansion of our variable substitution feature to include accessing fields, calling methods, and a few more neat tricks.
In Flux 7.10 (and previous versions), to use variable substitution, you were limited to simple data types (String, int, long, etc.) that had to be available already in one of the supported variable managers. This worked great for passing basic data between triggers and actions, but when things got more complex, it usually required adding a runtime data map or a prescript / postscript, which could quickly become difficult to manage.
For example, if you had a File Exist Trigger and just wanted to know how many files it found, you would first need to add a prescript to pull the number of files out of its result and store that in a new variable:
flowContext.put("numberOfResults", flowContext.get("RESULT").filename_matches.size());
Which you could then access directly using variable substitution:
${numberOfResults}
This came with some problems, though – specifically, since the variable had to be generated in one place and accessed in another, it was difficult to see who was generating that value, and where. Unless you had designed the flow chart initially and knew where that prescript was located, it could be a bit difficult to maintain or update the flow chart in the future.
One of the cool new features in Flux 7.11, then, is to “cut out the middleman” by making method calls and fields available directly within the substitution syntax itself. This means that instead of using a prescript, you could just directly access that information in the substitution itself:
${RESULT.filename_matches.size()}
Not only does this mean you can avoid using an extra prescript, but you can also see directly in the substituted field exactly where that value is coming from.
To cut back even further on the number of prescripts and postscripts you might need to use, the new variable substitution adds support for some new concepts like IF statements:
<#if MY_VARIABLE == 1> Test was true! </#if>
For loops:
<#list MY_COLLECTION as THIS_ITEM>
<#if THIS_ITEM % 2 == 0>%{THIS_ITEM}</#if>
</#list>
And some built-in String and numeric functions, including support for numeric operators, substrings, date and time functions, String length substitution, and even built-in HTML, XML, and XHTML encoding:
${MY_STRING?xml}
These are just some of the great new features that Flux 7.11 brings. Head to our website to see a complete list of features, find 7.11 downloads, and more!