Cannot Index type Number (Integer) into type Number (Integer)

Hi All, 

I'm getting the following error after some code changes in my interface: 

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!queryFilter [line 37]: Invalid index: Cannot index type Number (Integer) into type Number (Integer)

I added a new local variable to try and display a RO field that wasn't showing properly - I used the same query logic for this variable as I did for another -- here is the code for the variables: 

load(
  local!pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 1),
  local!studyCoordinator: a!queryEntity(
    entity: cons!CTM_ExternalUsers_DSE,
    query: a!query(
      selection: a!querySelection(
        columns: (a!queryColumn(field: "displayName"))
      ),
      pagingInfo: local!pagingInfo,
      filter: a!queryFilter(
        field: "id",
        operator: "=",
        value: if(isnull(ri!site.studyCoordinator), "None", ri!site.studyCoordinator[1])
        )
      )),
  local!PrincipalInvestigator: a!queryEntity(
    entity: cons!CTM_ExternalUsers_DSE,
    query: a!query(
      selection: a!querySelection(
        columns:(a!queryColumn(field: "displayName"))
      ),
      pagingInfo: local!pagingInfo,
      filter: a!queryFilter(
        field: "id",
        operator: "=",
        value: ri!profile.principalInvestigator[1]
      )
    )),
  local!studyProfileSite: rule!CTM_getStudyProfileSiteBySiteID(ri!site.siteID),
  local!subInvestigator: a!queryEntity(
    entity: cons!CTM_ExternalUsers_DSE,
    query: a!query(
      selection: a!querySelection(
        columns: (a!queryColumn(field: "displayName"))
      ),
      pagingInfo: local!pagingInfo,
      filter: a!queryFilter(
        field: "id",
        operator: "=",
        value: if(isnull(ri!site.subInvestigator), "None", ri!site.subInvestigator[1])
      )
    )
  ),

And the code for the specific field I think it's having issue with -- the value is a number, but I want it to display the name not the number so I used the dot notation. Initially I had an expression rule that took the number value and displayed the name (to avoid using dot notation), but this didn't work either. 

            a!textField(
              label: "Site Investigator",
              labelPosition: "ADJACENT",
              value: local!subInvestigator.data.displayname,
              refreshAfter: "UNFOCUS",
              readonly: true,
              validations: {}
            ),

 

I don't get why it's not able to index a value of the same type? Even when I directly type ri!site.subInvestigator into the "value" of the queryEntity at line 40 it shows nothing even though the value displayed in the test input is the number 56, referring to someone in the External User DSE...

Thanks for any suggestions!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi when you perform ri!CDT.fieldname then the return type will be list of field type, and isnull() cannot evaluate nullability for list of items and hence None is getting pass as an Input for id field inside queryFilter.


    You can create a rule (replica of APN_isBlank()) to check whether the given input is null or not.

    Now you can configure your filter as mention below
    if(rule!APN_isBlank(ri!site.subInvestigator),
    {},
    a!queryFilter(
    field: "id",
    operator: "in",
    value: {ri!site.subInvestigator}
    )
    )

    This should resolve the problem which you have encountered. Hope this will be helpful.
Reply
  • 0
    Certified Lead Developer
    Hi when you perform ri!CDT.fieldname then the return type will be list of field type, and isnull() cannot evaluate nullability for list of items and hence None is getting pass as an Input for id field inside queryFilter.


    You can create a rule (replica of APN_isBlank()) to check whether the given input is null or not.

    Now you can configure your filter as mention below
    if(rule!APN_isBlank(ri!site.subInvestigator),
    {},
    a!queryFilter(
    field: "id",
    operator: "in",
    value: {ri!site.subInvestigator}
    )
    )

    This should resolve the problem which you have encountered. Hope this will be helpful.
Children
  • HI Alok & everyone - thanks for the replies. I get that the form THINKS the value is null, but what I'm confused about is that my test value on the Interface Inputs shows a number value in site.subInvestigator so why is the form still blank?

    Like @ashokv mentioned, the "none" text value in the If statement was causing the Red error, so I removed it to get rid of the error, but I'm still confused why it was choosing that over the value provided by the input?

    I specifically chose a record that had a value for site.SubInvestigator in my Test Values so in referencing this in the queryFilter, shouldn't it see that value?