none
Not gettign the correct data by using the CAML Query RRS feed

  • Question

  • Hi

    I am using the below query to get the data in a order by Country name but it is loading randomly, what is wrong in the query

     camlQueryFlag.set_viewXml(
                            '<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
                            '<Value Type=\'Number\'>1</Value></Geq></Where>' +
                            '<OrderBy><FieldRef Name=\'Title\' Ascending=\'TRUE\'/></OrderBy></Query>' +
                            '<RowLimit>300</RowLimit></View>'
                        );

    Thanks

    Paru


    Paru


    • Edited by Paru Upreti Friday, February 9, 2018 3:31 PM
    Friday, February 9, 2018 1:19 PM

All replies

  • in this query items are ordered by Title field. Does it contain country names or there is other field for them? If there is another field you need to use that in OrderBy instead of Title. Plus try to add Ascending attribute there:

    <OrderBy>
        <FieldRef Name='Title' Ascending='TRUE' />
    </OrderBy>


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - https://github.com/sadomovalex/camlex


    Friday, February 9, 2018 1:49 PM
  • Thanks for the reply

    Now i am using thie below query

       camlQueryFlag.set_viewXml(
                            '<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
                            '<Value Type=\'Number\'>1</Value></Geq></Where>' +
                            '<OrderBy><FieldRef Name=\'Title\' Ascending=\'TRUE\'/></OrderBy></Query>' +
                            '<RowLimit>300</RowLimit></View>'
                        );

    but still it doesn't work , 'country name' is the display name of the field the internal name is Title.


    Paru


    • Edited by Paru Upreti Friday, February 9, 2018 2:10 PM
    Friday, February 9, 2018 2:08 PM
  • Hi,

    Your caml query seems fine, could you provide your detailed sample code so we could try to check.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, February 12, 2018 9:06 AM
  • what do you mean by "doesn't work": does it return more/less items than it should or only sort order is incorrect? If only sorting is incorrect: what language is used for storing county names? Is it Latin based or not?

    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - https://github.com/sadomovalex/camlex

    Monday, February 12, 2018 2:45 PM