OFBiz <eca> not clearing parameters between triggers

Viewed 88

I have an entity condition action <eca> defined like this:

    <eca service="importAccount" event="invoke" run-on-error="true" run-on-failure="true" >
        <set field-name="serviceName" value="importAccount" />
        <set field-name="parameters.acctNum" env-name="${acctNum}" />
        <action service="serviceLogging" mode="sync"/>
    </eca>

When I run importAccount from OFBiz's webtools with an acctNum parameter, the serviceLogging service gets triggered and sees the parameter just fine.

If I then run importAccount again without an acctNum parameter, the serviceLogging service gets triggered however it gets the parameter from the previous run. I would expect it to get null since I didn't enter a parameter for the second run. The serviceLogging service gets the parameter from the first run on every subsequent run that I do without a parameter

Inside serviceLogging I have tried doing:


context.remove("parameters") at the end of the service
context.put("parameters", null) at the end of the service


but I keep getting that initial parameter on every run. How can I stop this from happening?

Thank you

EDIT

I believe I have found an answer. Setting a default-value prevents the SECA from getting the previous runs input parameter. However I cannot figure out how to set the default-value to null. Here is the service def:

    <service name="importAccounts" engine="java"
         location="com.hotwaxmedia.dsi.migration.MigrationServices" invoke="importAccounts" auth="true" transaction-timeout="14400">
        <description>Import Accounts from Legacy</description>
        <attribute name="glNumb" mode="IN" type="String" optional="true" default-value=" "/>
    </service>

However, when no input parameter is set this will pass in a space to the service, but I am looking for it to pass in a null. I have tried:

default-value="" <-- This will continue passing the previous run's parameter..

default-value="null" <-- This will pass in the string "null"

default-value="${groovy: return null}" <-- This will pass in the string "${groovy: return null}"

Have also tried:

    <attribute name="glNumb" mode="IN" type="String" optional="true"> 
      <default-value>
        <null xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      </default-value>
    </attribute>

But this just uses the previous run's input parameter as well.

Do you know how to set a default-value of null?

0 Answers
Related