Open adeojo opened 3 months ago
The compilation of the accumulator would occur prior to the execution of rules and outside of that context, which is likely the source of the error:
Unable to resolve symbol: ?billingDates in this context
In the sense that at session creation time, its trying to construct the field accessor function:
(acc/sum #((calculate-trading-dates (.getEffectiveDate %) (.getTerminateDate %) ?billingDates) % ))
which attempts to reference a binding scoped to an execution time variable.
Off the cuff, i'd probably defer that sort of logic to the RHS for calculation rather than the accumulator if possible.
Other contributors mentioned(off-thread) an alternative of introducing intermediate facts to house this sort of data for easier accumulation.
Something akin to:
(defrecord DlpFirmWithTradingDates [trading-dates dlp-firm])
(r/defrule my-rule
"Sample Rule"
[?billingDates <- BillingDates]
[?dlpFirm <- DlpFirm
(= portId "PrimaryDLP")
(= ?tradingDates (calculate-trading-dates effectiveDate terminateDate ?billingDates))]
=>
(r/insert! (->DlpFirmWithTradingDates ?tradingDates ?dlpFirm)))
then a subsequent rule to accumulate the intermediate facts.
Will give this a try. thx
I have the following custom function
The above function is used in a rule as below
When I test the above rule, I get the error:
FYI :The DLPFirm POJO does not have BillingDates
Any ideas how I can use the the function with an accumulator ?