...
Before Bee’s Knees, types were not properly always converted for Groovy Sandbox (such as DomainObject to Map) when used as a closure parameter.
In this example, the code works but the cor
parameter is not a Map (as it should be) but some , but an instance of DomainObject (a CompensationRecord in this case):
Code Block |
---|
def result List cors = api.find("COR", 0, 1, null, null, Filter.equal("label", "SC_basic_logic"))?.collect() cors.each {def cor -> result = cor } return result |
Note that if you explicitly set the type of cor
to Map, the code will fail with an error.
Since Bees Knee's, the conversion of types in closure parameters is automatic just for LocalDateTime -> Date (which is safe in terms of backward compatibility). Other types will not be converted by default, because the conversion might break the existing Groovy code; instead . Instead there will be a specific warning in logs, i.e.:
...
If you see this kind of log message, you should consider adding an Advanced Configuration Option filterGroovyClosureParameterType=true which will enable automatic conversion for Groovy closure parameters as it should be and will also remove the log message. Then check your Groovy code for possible errors and fix them by using a proper data type, i.e. DomainObject will be converted to Map.
When filterGroovyClosureParameterType=true is not set, then:
Will not work:
cors.each {Map cor ->
Will work:
cors.each {def cor ->
cor
is an instance of some DomainObject class.
When filterGroovyClosureParameterType=true is set, then:
Both will work:
cors.each {Map cor ->
cors.each {def cor ->
But you will not be able to access the DomainObject because it was converted to a Map.