Issue with Pagination Widget in ThingWorx mashup with QueryImplementingThingsOptimizedWithTotalCount
Hello All,
I am currently facing an issue with the pagination widget in my ThingWorx mashup. The initial load of the data works perfectly, but when I select a page number from the pagination widget, the service fails to return the correct data and gives an error code 500(Error executing service Test1.Message: : Wrapped java.lang.NullPointerException-See Script Error Log for more details.). Specifically, the last page fails when it has fewer rows than the page size.
Here is a summary of my setup:
-
Service Configuration:
- I am using the QueryImplementingThingsOptimizedWithTotalCount service to fetch data with pagination.
- The service parameters include maxItems, offset, and query.
-
Pagination Logic:
- The offset is calculated as (pageNumber - 1) * pageSize.
- The service correctly handles the initial load but fails when navigating to the last page with fewer rows.
-
Code Snippet:
var offset_Value = (pageNumber - 1) * pageSize; let assetList = ThingTemplates["BasePlatform"].QueryImplementingThingsOptimizedWithTotalCount({ maxItems: pageSize, offset: offset_Value, propertyNames: propertylist, query: query });
var numRows = totalAssets; var startRow = Math.max(0, (pageNumber - 1) * pageSize); var endRow = Math.min(startRow + pageSize, localInfoTable.length); for (var r = startRow; r < endRow; r++) { paginatedResult.addRow(assetList.getRow(r)); } result.AddRow({numberOfRows: numRows, assetData: paginatedResult}); - Problem:
- The service works fine on the initial load but fails with error code 500 when navigating to the next page using the pagination widget.
- The last page fails when it has fewer rows than the page size.
I would appreciate any guidance or suggestions on how to resolve this issue. Thank you!

