Expression evaluation error at function a!forEach

We have the code below which is encountering “Expression evaluation error at function a!forEach [line 30]: Error in a!forEach() expression during iteration 25: Expression evaluation error : Cannot compare incompatible operands of type Date with Timezone and type Null.”

 

local!months: rule!CAS_calculateNumberOfMonths(ri!policy.policyEffectiveDate, ri!policy.expirationDate),

.

.

.

{

  with(

    /*backdate is first day of open accounting month*/

    local!backDate: rule!CAS_firstDayofAccountingMonthByDate(

      date: today()

    ),

    /*transaction for each month of the policy*/

    a!forEach(

      items: enumerate(

        local!months

      ),

      expression: with(

        local!firstMonth: month(

          ri!policy.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!policy.policyEffectiveDate

          ) + 1,

          year(

            ri!policy.policyEffectiveDate

          )

        ),

        /*for first item, transaction date is policy effective date. for all others, first of month*/

        local!expectedTransDate: if(

          fv!index = 1,

          ri!policy.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

            )

          )

        ),

.

.

.

 

Here is the data input we are using. We are a little confused that when the policyEffectiveDate and expirationDate is less than 25 error is not encountered.

 

policyId: 2007892 practiceId: 1 projectId: 474 carrierPolicyId: "30339" coverageCodeId: 34 carrierCodeId: 1630 compensationTypeId: 2453 numberOfLives: null (Number (Integer)) annualPremium: 0 flatFee: null (Number (Decimal)) contractLineId: 650 pepm: null (Number (Decimal)) commissionPercent: 1.75 tieredValue: null (Number (Decimal)) premiumModeId: 58 policyEffectiveDate: 1/1/2018 isSubbroker: false expirationDate: 6/30/2020 policyStatusId: 6 workflowStatusId: 12 lastUpdatedDatetime: 6/3/2020 1:11 PM CDT lastUpdatedBy: "victor.b.victorioso" isNac: false taskId: 5130 subbrokerId: null (Number (Integer)) processor: "victor.b.victorioso" requestorId: 8926 assignee: "[Group:41]" sb_percentOfCommission: null (Number (Decimal)) sb_paymentEndDate: null (Date) isAccrual: null (Boolean) appianFolderId: 52163 hasBeenRenewed: null (Boolean) isRenewAccrual: null (Boolean) isRenewCash: null (Boolean) oldPolicyId: null (Number (Integer)) isDeleted: false

Parents
  • 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)

Reply
  • 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)

Children
No Data

 Discussion posts and replies are publicly visible