Pagination Works From Record Source but Not Record Listing

I have a non-synced REST API that I am using to fetch data via an integration. This endpoint supports paging. In both the record data source and the integration, when I put a a!pagingInfo(x, y), in the pagingInfo test inputs, the data increments through pages correctly according to the values I give for x and y.

But, in the data model test listing and the record list URL, the first 50 records appear (as expected) with the correct record total (more than 1,000), but when I click the next button, the next page is blank and says "No items available". I can click the previous button, and the first 50 records display again. The Paging Info drop down on the data model page is mapped to the correct rule input on the record data source.

The Appian version is 23.2.

Here is my code for the dataSubset in the record data source:

a!dataSubset(
  startIndex: ri!pagingInfo.startIndex,
  batchSize: ri!pagingInfo.batchSize,
  totalCount: local!integrationResponse.result.body.total_items,
  data: a!forEach(
    local!integrationResponse.result.body.items,
    cast(
      'type!{urn:com:appian:types:YYY}YYY_MyRecordType',
      fv!item
    )
  ),
  identifiers: a!forEach(
    local!integrationResponse.result.body.items,
    fv!item.id
  )
),

I cannot seem to find anything wrong. What am I missing?

UPDATE:

The problem was that I needed to convert start index into a page number.

Much appreciation for the tremendous effort to help from @

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I do not see any obvious problems. Can you share more of your code? Especially I am interested in that local!integrationResponse. Starting with the integration object itself, you need to validate each and every step, making sure that the correct values go in and come out.

    Two tips:

    - You can cast a list of items without a foreach. Just cast to a!listType(<YOUR_RECORD_TYPE>).

    - You can extract all values form a list of items without a foreach -> "local!integrationResponse.result.body.items.id"

  • After your suggestions, here is my updated record data source:

    a!localVariables(
      /* Call the integration and store the response in a local variable */
      local!integrationResponse: rule!YYY_searchRecords(
        pagingInfo: ri!pagingInfo,
        searchText: ri!searchText
      ),
    
      if(
        /* This will return true if the integration succeeds */
        local!integrationResponse.success,
    
        /* If needed, modify the expression below to return a list of maps, dictionaries, or CDTs that map to your record data */
        /* local!integrationResponse.result.body, */
        
        a!dataSubset(
          startIndex: ri!pagingInfo.startIndex,
          batchSize: ri!pagingInfo.batchSize,
          totalCount: local!integrationResponse.result.body.total_items,
          sort: ri!pagingInfo.sort,
          data: cast(
            a!listType('recordType!{ed44efbc-d562-4c71-b1ee-87905a73c395}YYY Record'),
            local!integrationResponse.result.body.items
          ),
          identifiers: local!integrationResponse.result.body.items.id
        ),
        
    
        /* If the integration is unsuccessful, handle accordingly */
    
        if(
          /* Note: handling of out of bounds exceptions varies by web service */
          tointeger(index(local!integrationResponse.result, "statusCode", 0)) = 416,
    
          /* If this is an out of bounds error, return an empty list to finish syncing */
          {},
    
          /* If this is a different error, return the integration error. */
          /* If you need additional logic to determine the error, use a!integrationError() in the integration to format the error displayed in the sync monitor */
          local!integrationResponse.error
        )
      )
    )

Reply
  • After your suggestions, here is my updated record data source:

    a!localVariables(
      /* Call the integration and store the response in a local variable */
      local!integrationResponse: rule!YYY_searchRecords(
        pagingInfo: ri!pagingInfo,
        searchText: ri!searchText
      ),
    
      if(
        /* This will return true if the integration succeeds */
        local!integrationResponse.success,
    
        /* If needed, modify the expression below to return a list of maps, dictionaries, or CDTs that map to your record data */
        /* local!integrationResponse.result.body, */
        
        a!dataSubset(
          startIndex: ri!pagingInfo.startIndex,
          batchSize: ri!pagingInfo.batchSize,
          totalCount: local!integrationResponse.result.body.total_items,
          sort: ri!pagingInfo.sort,
          data: cast(
            a!listType('recordType!{ed44efbc-d562-4c71-b1ee-87905a73c395}YYY Record'),
            local!integrationResponse.result.body.items
          ),
          identifiers: local!integrationResponse.result.body.items.id
        ),
        
    
        /* If the integration is unsuccessful, handle accordingly */
    
        if(
          /* Note: handling of out of bounds exceptions varies by web service */
          tointeger(index(local!integrationResponse.result, "statusCode", 0)) = 416,
    
          /* If this is an out of bounds error, return an empty list to finish syncing */
          {},
    
          /* If this is a different error, return the integration error. */
          /* If you need additional logic to determine the error, use a!integrationError() in the integration to format the error displayed in the sync monitor */
          local!integrationResponse.error
        )
      )
    )

Children
No Data