web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting records with offset

(0) ShareShare
ReportReport
Posted on by

Hello CRM masters.
I need to get data records with offset like this:
SELECT * FROM my_table ORDER BY order_field ASC
LIMIT 10, <offset_number>
where <offset_number> is an index of the record to start from.

I use RSSBus as transport and c# as back-end in my portal. As I see it is impossible to get offset in such way.
I tried to use offset() or row_number() but got errors.

 Please show me the right way to do it. Maybe it is written about in some documentation, but I can't find it.
 Thank you  for any help

PS

it is a copy of my question here https://social.microsoft.com/Forums/en-US/c4c11704-964c-4c26-a88c-0afab4b392e0/getting-records-with-offset?forum=crmdevelopment

I'm sorry if I violate any rules. I don't know were is the best place to post it.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    Are you using sql query to fetch the data or CRM API ? If you are using crm API to retrieve the data use the fetchxml with paging option to get same results like offset and skip in sql

    Here is the sample code that shows how to get paging results using fetchxml query

    msdn.microsoft.com/.../gg327917.aspx

  • Community Member Profile Picture
    on at

    I'm using RSSBus which uses some kind of wrapper for fetchxml. So if I pass sql query throught it I get fetchxml as result.

    I have tried to make a queryExpression (without rssbus) such as in example from your link and I've got full data receiving in a loop. So if I have a large result, it takes too much time.

    Query result contains the flags "MoreRecords" which rules the paging , as I see.  

    Certainly, I can limit record count (fetch the data for the nearest 10 pages etc.).

    Is this the only way?

  • Royal King Profile Picture
    27,686 on at

    I'm using fetchxml with paging in  kendo grid UI  and it works without any issue. I can set number of records per page as well i can get  particular page records by passing pagenumber in the fetchxml.In fetchxml there is no skip but you can specify page number to skip number of records.Check portion of the fetchxml code that is related to Paging.

    <fetch version='1.0' mapping='logical' count='5' page='2' PagingCookie='&lt;cookie page="1"&gt;&lt;way_target last="{6C034728-00F2-E111-A489-0050569D0006}" first="{6C034728-00F2-E111-A489-0050569D0006}" /&gt;&lt;/cookie&gt;'>
        <entity name='anc_arget'>
            <all-attributes />
        </entity>
    </fetch>

    It looks like you are getting all the result in one go thats why it's taking long time.If you fetch data by page number it will not take long time. WHen you query for first time you don't have to specify page number just specify count , this will get you 5 records
    for sub sequent calls pass page number and cookie returned from the previous call that wil get records page by page
    <fetch version='1.0' mapping='logical' count'5'>
        <entity name='anc_arget'>
            <all-attributes />
        </entity>
    </fetch>

    if you need records count as well then you need to user query expression version of the soap that will return records count as well as paging information
     
  • Community Member Profile Picture
    on at

    It works!

    Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans