Skip to main content
September 29, 2022
Question

Cannot apply operator [EQUALS] to field [type] when comparing to value [TypedValue[it=103,v={Text,Decimal,Date}]].

  • September 29, 2022
  • 6 replies
  • 1 view

if(
  isnull(ri!type),
  {},
  a!forEach(
    items: a!queryEntity(
      entity: cons!POINTER_TO_DSE,
      query: a!query(
        filter: a!queryFilter(
          field: "type",
          operator: "=",
          value: ri!type 
        ),
        pagingInfo: if(
          isnull(ri!pagingInfo),
          a!pagingInfo(1, - 1),
          ri!pagingInfo
        )
      ),
      fetchTotalCount: true
    ),
    expression: if(
      ri!type = "Text",
      updatedictionary(fv!item, { textField: true }),
      if(
        ri!type = "Decimal",
        updatedictionary(fv!item, { decimal: true }),
        if(
          ri!type = "Date/time",
          updatedictionary(fv!item, { dateTimeField: true }),
          if(
            ri!type = "Integer",
            updatedictionary(fv!item, { integer: true }),
            if(
              ri!type = "Date",
              updatedictionary(fv!item, { date: true }),
              if(
                ri!type = "Boolean",
                updatedictionary(fv!item, { boolean: true }),
                null
              )
            )
          )
        )
      )
    )
  )
)

Rule inputs are ri!type (text, array) and ri!pagingInfo

Expression evaluation error at function a!queryEntity [line 5]: Cannot apply operator [EQUALS] to field [type] when comparing to value [TypedValue[it=103,v={Text,Decimal,Date}]].

I keep getting the error above after I set type to: {"Text", "Decimal", "Date"}

The idea is after a user choose the type of field, a boolean field is flagged when conditions are met. It should be possible to make n types of field.

Can anybody fix this? Thanks!

    6 replies

    harshitb6843
    September 29, 2022
    I keep getting the error above after I set type to: {"Text", "Decimal", "Date"}

    What do you mean by this?

    September 29, 2022

    I test with those values

    September 29, 2022

    "Rule inputs are ri!type (text, array) " in case of array use 'in'

    a!queryFilter(
              field: "type",
              operator: "in",
              value: ri!type 
            ),

    September 29, 2022

    This is the error I get: Could not cast from Text to QueryFilter. Details: CastInvalidCould not cast from Text to QueryFilter. Details: CastInvalid

    harshitb6843
    September 29, 2022

    What Ujjwal said makes sense to me. You must have applied it in the wrong way. Added Ujjwal's block to your code.

    if(
      isnull(ri!type),
      {},
      a!forEach(
        items: a!queryEntity(
          entity: cons!POINTER_TO_DSE,
          query: a!query(
            filter: a!queryFilter(
              field: "type",
              operator: "in",
              value: ri!type 
            ),
            pagingInfo: if(
              isnull(ri!pagingInfo),
              a!pagingInfo(1, - 1),
              ri!pagingInfo
            )
          ),
          fetchTotalCount: true
        ),
        expression: if(
          ri!type = "Text",
          updatedictionary(fv!item, { textField: true }),
          if(
            ri!type = "Decimal",
            updatedictionary(fv!item, { decimal: true }),
            if(
              ri!type = "Date/time",
              updatedictionary(fv!item, { dateTimeField: true }),
              if(
                ri!type = "Integer",
                updatedictionary(fv!item, { integer: true }),
                if(
                  ri!type = "Date",
                  updatedictionary(fv!item, { date: true }),
                  if(
                    ri!type = "Boolean",
                    updatedictionary(fv!item, { boolean: true }),
                    null
                  )
                )
              )
            )
          )
        )
      )
    )