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

  • Hi Sarah. I think the value in the a!queryFilter() doesn't seem appropriate. Considering that "id" field is a number, you should provide number as its value. But it seems you are passing some text(since you are checking if the value is null, then it as "None" which is text). filter parameter is used to filter the query results that are queried. If you want to display name instead of number, then you should do those manipulations in either in textfield or in the grid field wherever u r planning to do so.

    Also, please check whether you are getting all the values in the ri!site cdt. For testing purpose, you can pass ri!site.subInvestigator to a local variable and pass it as a query filter value.

    I suggest you to check the query receipes provided by Appian

    docs.appian.com/.../Query_Recipes.html
  • 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.
  • 0
    Certified Lead Developer
    ,

    I suspect that, the value in ri!site.subInvestigator is not available. Please use index(ri!site.subInvestigator,1,{}). If it doesn't work have a null check by using rule!APN_isBlank() and process further.
  • 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?

  • the problem is with ri!site.studyCoordinator[1]) being called inside the queryfilter. if ri!site.studyCoordinator is a single value then you won't be able to index into it....might need a check of if(count(ri!site.studyCoordinator) =1, ri!site.studyCoordinator, ri!site.studyCoordinator[1])
  • I'm not worried about the study coordinator value -- that is potentially multiple that's why it's choosing [1]. What I need to display is site.subInvestigator - thanks!