Groovy Scripting

Sometime while importing large data, it’s required to process the data and transform it according to our needs. Doing this manually on all the CSV files is time consuming and error prone. Hoverer, Axelor Development Kit provides embed groovy scripting support to process/transform the data during the import process.

You can specify inline groovy expressions to process individual field value, provide default field value or can process the newly constructed data object. This should be specified in the mapping file like this:

<?xml version="1.0"?>
<csv-inputs xmlns=""


  <input file="sale-orders.csv" type=""

    <!-- transform boolean value into 'true' or 'false' -->
    <bind column="confirmed" to="confirmed"
      eval="confirmed ==~ /^(T|Y|1)$/ ? 'true' : 'false'"/>



First, we can provide any method with call attribute to input tag to post-process the data object once it’s populated but before persisting to the database.

Here is an example groovy script:


import com.axelor.db.JpaSupport

class Validators extends JpaSupport {

    SaleOrderService soService

    def validateSaleOrder(Object bean) {
        assert bean instanceof Order
        Order so = (Order) bean


        println("Date: $so.orderDate")
        println("Customer: $so.customer.firstName $so.customer.lastName")
        println("Items: $so.items.size")

        int count = all(Contact).count()
        assert count > 1

        return bean

Second, you can specify simple groovy expression via eval attribute. This expression will be evaluated with the context of current CSV record’s (column name → value) map.

You can see that,

  • the values of column confirmed is processed to convert in valid boolean value.

  • default value for confirmDate is provided with groovy expression.