<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issue with Pagination Widget in Thingworx masup with QueryImplementingThingsOptimizedWithTota... in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1013040#M69631</link>
    <description>&lt;P&gt;Hello &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/923259"&gt;@Bhavya_PC&lt;/a&gt;&lt;/SPAN&gt; ,&lt;BR /&gt;&lt;BR /&gt;It appears that your &lt;A href="https://community.ptc.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-Thingworx-masup-with/m-p/1006821#M69382" target="_blank"&gt;question&lt;/A&gt;, has been provided next steps and possibly a solution.&amp;nbsp; For the benefit of other Community Members who may have the same question, it would be great if you could designate it as the Accepted Solution.&lt;BR /&gt;&lt;BR /&gt;In the event that this response did not answer your question, please post your current status so that we can continue to support.&lt;BR /&gt;&lt;BR /&gt;Thanks for using the PTC Community!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;pehowe&lt;/P&gt;</description>
    <pubDate>Mon, 28 Apr 2025 19:36:58 GMT</pubDate>
    <dc:creator>PEHOWE</dc:creator>
    <dc:date>2025-04-28T19:36:58Z</dc:date>
    <item>
      <title>Issue with Pagination Widget in ThingWorx mashup with QueryImplementingThingsOptimizedWithTotalCount</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1006821#M69382</link>
      <description>&lt;P&gt;Hello All,&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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&amp;nbsp;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.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Here is a summary of my setup:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Service Configuration:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I am using the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;QueryImplementingThingsOptimizedWithTotalCount&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;service to fetch data with pagination.&lt;/LI&gt;
&lt;LI&gt;The service parameters include&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;maxItems,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;offset, and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;query.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Pagination Logic:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;offset&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is calculated as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(pageNumber - 1) * pageSize.&lt;/LI&gt;
&lt;LI&gt;The service correctly handles the initial load but fails when navigating to the last page with fewer rows.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Code Snippet:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;var offset_Value = (pageNumber - 1) * pageSize;

let assetList = ThingTemplates["BasePlatform"].QueryImplementingThingsOptimizedWithTotalCount({
    maxItems: pageSize,
    offset: offset_Value,
    propertyNames: propertylist,
    query: query
});&lt;/PRE&gt;
&lt;PRE&gt;&lt;BR /&gt;var numRows = totalAssets;
var startRow = Math.max(0, (pageNumber - 1) * pageSize);
var endRow = Math.min(startRow + pageSize, localInfoTable.length);

for (var r = startRow; r &amp;lt; endRow; r++) {
    paginatedResult.addRow(assetList.getRow(r));
}

result.AddRow({numberOfRows: numRows, assetData: paginatedResult});&amp;nbsp;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;Problem:
&lt;UL&gt;
&lt;LI&gt;The service works fine on the initial load but fails with error code 500 when navigating to the next page using the pagination widget.&lt;/LI&gt;
&lt;LI&gt;The last page fails when it has fewer rows than the page size.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I would appreciate any guidance or suggestions on how to resolve this issue. Thank you!&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 20:53:22 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1006821#M69382</guid>
      <dc:creator>Bhavya_PC</dc:creator>
      <dc:date>2025-04-28T20:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Pagination Widget in Thingworx masup with QueryImplementingThingsOptimizedWithTotalCo</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1006993#M69394</link>
      <description>&lt;P&gt;Put in loggings to find out which call causes the NullPointerException. Then find out if you give the service call valid parameters.&lt;/P&gt;
&lt;P&gt;If so, that suggests a product issue and you need a ticket with support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, are you really adding the rows to the result? The service is called &lt;STRONG&gt;A&lt;/STRONG&gt;ddRow, not&lt;STRONG&gt; a&lt;/STRONG&gt;ddRow.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 10:40:10 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1006993#M69394</guid>
      <dc:creator>Rocko</dc:creator>
      <dc:date>2025-03-27T10:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Pagination Widget in Thingworx masup with QueryImplementingThingsOptimizedWithTota...</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1007775#M69425</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/923259"&gt;@Bhavya_PC&lt;/a&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the response to your post was helpful, please mark it as the Accepted Solution for the benefit of others in the Community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Sharon&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 19:23:41 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1007775#M69425</guid>
      <dc:creator>slangley</dc:creator>
      <dc:date>2025-03-31T19:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Pagination Widget in Thingworx masup with QueryImplementingThingsOptimizedWithTota...</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1008578#M69453</link>
      <description>&lt;P&gt;Hello &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/923259"&gt;@Bhavya_PC&lt;/a&gt;&lt;/SPAN&gt; ,&lt;BR /&gt;&lt;BR /&gt;I always like an example which works. So I did a little search in the Knowledge base and found &lt;A href="https://www.ptc.com/en/support/article/CS360936" target="_blank"&gt;&lt;STRONG&gt;Article - CS360936 - &lt;/STRONG&gt;How to prepare data source for ThingWorx Pagination widget&lt;/A&gt;&lt;BR /&gt;This article contains a link &lt;A href="https://support.ptc.com/images/cs/articles/2023/5/1684404949awdB/PageSample.zip?_gl=1*zozdpj*_gcl_au*MTQ1MDY4NDExLjE3Mzg1ODkxMzUuNDUwNDgyMDkyLjE3NDM3MDQ5NDIuMTc0MzcwNDk0Mg..*_ga*MTAyMjYzNzEyMi4xNzM4NTg5MTM1*_ga_7NMP2MSYPM*MTc0MzcwNDkzMS4xNDAuMC4xNzQzNzA1MzQxLjYwLjAuMA..*_ga_CBN5QVB9VJ*MTc0MzcwNDkzMS4xNzMuMS4xNzQzNzA0OTQyLjAuMC4w" target="_blank"&gt;&lt;U&gt;Sample entity&lt;/U&gt;&lt;/A&gt; to a zip file This file contains 3 XML files which you can import and then you will have a working example of pagination.&lt;BR /&gt;&lt;BR /&gt;Let me know if this helps&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;/P&gt;
&lt;P&gt;Pehowe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2025 18:38:06 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1008578#M69453</guid>
      <dc:creator>PEHOWE</dc:creator>
      <dc:date>2025-04-03T18:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Pagination Widget in Thingworx masup with QueryImplementingThingsOptimizedWithTota...</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1013040#M69631</link>
      <description>&lt;P&gt;Hello &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/923259"&gt;@Bhavya_PC&lt;/a&gt;&lt;/SPAN&gt; ,&lt;BR /&gt;&lt;BR /&gt;It appears that your &lt;A href="https://community.ptc.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-Thingworx-masup-with/m-p/1006821#M69382" target="_blank"&gt;question&lt;/A&gt;, has been provided next steps and possibly a solution.&amp;nbsp; For the benefit of other Community Members who may have the same question, it would be great if you could designate it as the Accepted Solution.&lt;BR /&gt;&lt;BR /&gt;In the event that this response did not answer your question, please post your current status so that we can continue to support.&lt;BR /&gt;&lt;BR /&gt;Thanks for using the PTC Community!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;pehowe&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 19:36:58 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Issue-with-Pagination-Widget-in-ThingWorx-mashup-with/m-p/1013040#M69631</guid>
      <dc:creator>PEHOWE</dc:creator>
      <dc:date>2025-04-28T19:36:58Z</dc:date>
    </item>
  </channel>
</rss>

