We have the code below which is encountering “Expression evaluation error at function a!forEach [line 12]: Error in a!forEach() expression during iteration 25: Expression evaluation error : Cannot compare incompatible operands of type Date with Timezone and type Null.”
/*if(*/ /*exact(ri!clientPlanner.segment, cons!CAS_SEGMENT_LARGE),*/ /*{*/ with( /*backdate is first day of open accounting month*/ local!backDate: rule!CAS_firstDayofAccountingMonthByDate(date: today()), local!months: rule!CAS_calculateNumberOfMonths(ri!policyEffectiveDate, ri!expirationDate), local!currency: "USD", local!annualAmount: ri!annualPremium*(ri!commissionPercent/100)*local!months/12 , /*transaction for each month of the policy*/ a!forEach( items: enumerate(local!months), expression: with( local!firstMonth: month(ri!policyEffectiveDate), /*the next month will be the first month + index*/ local!monthPlus1: local!firstMonth+fv!item, /*gets actual next month*/ local!nextMonth: if( local!monthPlus1>12, local!monthPlus1-12, local!monthPlus1 ), /*gets year for the next month*/ local!yearForNextMonth: if( local!monthPlus1>12, year(ri!policyEffectiveDate)+1, year(ri!policyEffectiveDate) ), /*for first item, transaction date is policy effective date. for all others, first of month*/ local!expectedTransDate: if( fv!index=1, ri!policyEffectiveDate, date(local!yearForNextMonth, local!nextMonth, 1) ), /*back date if already passed the closing day*/ local!accountingDate: if( today()>rule!CAS_getLastAccountingDayOfMonthByDate(compareDate: local!expectedTransDate), local!backDate, if( today()>local!expectedTransDate, if( month(today())=month(rule!CAS_getLastAccountingDayOfMonthByDate(compareDate: local!expectedTransDate)), local!expectedTransDate+daysinmonth(month(local!expectedTransDate), year(local!expectedTransDate))-1, today()
), local!expectedTransDate ) ), local!amount: if( fv!index<local!months, round(local!annualAmount/local!months), sum( round(local!annualAmount,2)-round(local!annualAmount/local!months)*(local!months-1) ) ), /*creates transaction object*/ rule!CAS_createTransactionObject( allocationTypeId: cons!CAS_TRANSACTION_TYPE_ID_ACCRUAL, batchTypeId: cons!CAS_REFERENCE_DATA_ID_BATCH_TYPE_ONLINE, amount: local!amount, isAccrual: true, transactionDate: local!expectedTransDate, accountingDate: local!accountingDate, transactionTimestamp: now(), recordId: "20097314", recordTypeId: cons!CAS_RECORD_TYPE_ID_POLICY, policyId: "20097314", transactionCurrency: local!currency ) ) ) )
We are a little confused that when the policyEffectiveDate and expirationDate is less than 12 error is not encountered for Large segment
Discussion posts and replies are publicly visible
What do you have on line 30?.
Anyways, the error seems clear to me, you are doing null + something and as null is not a dataType, it gives you that error.
Check what is on line 30, probably you have a variable that on the row 25 of your data type is null.
Quick way of solving is to add some sort of conditions as follows
if(isnull(local!yourVariable), 0, local!yourVariable)
Hi Manuel, thanks for your insight. We're encountering the error if the difference of two dates is greater than 12 months