Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

FetchXML returns different number of results between Advanced Find and SDK

Posted on by 142

I have an Advance Find that returns 31 records. If I download the FetchXML from that Advanced Find and then either run it in VB using the SDK or using XRMToolKit FetchXML Tester it only returns 17 records. Anyone know why this is?

*This post is locked for comments

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    Just to add a bit more to this:

    • If you use the Today operator, CRM will use the current user's timezone to determine the range of datetime values. This means that users in different time zones could get different results
    • If you use the On operator, then you specify the DateTime. This can include the specific timezone, using the ISO 8601 format. 
  • Verified answer
    Arpit Shrivastava Profile Picture
    Arpit Shrivastava 7,518 User Group Leader on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    Hey Jon,

    Is there any Date/Time type of field in your Fetch XML conditions?

    When working with dates, always remember to convert to UTC since that is how CRM stores them in the database.

    The native CRM Advanced find is going to look at whatever the current user's time zone is, and convert that whatever time they enter into the advanced find to UTC before performing a SQL query.

    Your custom code/plugins will need to do the same thing.

    Hope it helps.

    If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.

    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

     

  • Verified answer
    viperdudeuk Profile Picture
    viperdudeuk 142 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    Found the problem

    If I use

    DateTime today = DateTime.Now;

    string fetchXMLDate = today.Year.ToString() + "-" + today.Month.ToString() + "-" + today.Day.ToString();

    I get the different results

    If I use the today operator in the FetchXML I get the same results. No idea why that is.

  • viperdudeuk Profile Picture
    viperdudeuk 142 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    I am using the same server, same organisation and same credentials confirmed. I have tried a different browser with the cache cleared and still I get different results between the browser and XRMToolbox

  • Hari Narayanan Profile Picture
    Hari Narayanan 589 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    It is not possible, please check for any saved credentials which browser might be using for login. One other option would be that you are connecting to different environment in XRM toolbox.

    If you are connecting to same organization, same credentials, you will get same result in any way or retrieval.

  • viperdudeuk Profile Picture
    viperdudeuk 142 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    I am copying the FetchXML directly from the Advanced Find and pasting it into the XRMToolBox FetchXMLTester using the same username and password and I get the different results.

  • gdas Profile Picture
    gdas 50,085 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    Hello Jon ,

    Its not possible , seems something is difference in your code , could you please check in XRMToolBox fetchXML tester once .

    Could you please share your code and fetchXML once.

  • Hari Narayanan Profile Picture
    Hari Narayanan 589 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    There are two possiblities which could cause this issue.

    1. Different user names being used between browser and toolbox.

    2. Fetch Xml have additional filters which filters some more record.

  • viperdudeuk Profile Picture
    viperdudeuk 142 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    I am using the same username and password for both the application and the code.

  • Hari Narayanan Profile Picture
    Hari Narayanan 589 on at
    RE: FetchXML returns different number of results between Advanced Find and SDK

    It must be the different user credentials being used with different access levels. Please check the user account used to connect to Dynamics 365.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans