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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Fetchxml compare string with greater than operator

(0) ShareShare
ReportReport
Posted on by

I want to search for companies between a range of zip codes.

Example:

zip code < 50000

and

zip code > 40000

But it seems, that I can't do that with the advanced find, correct ? Is it possible to do this with fetchxml ?

BTW, the zip code can also be something like: AV300

In this case it should also do the same string comparison.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi Donny,

    Yes, you can do that through fetch xml, I just ran this test looking for an account with postal code 12345.

    <fetch count="25">
    	<entity name="account">
    		<attribute name="address2_postalcode" />
            <filter type="and">
                <condition attribute="address2_postalcode" value="12344" operator="gt"/>
            </filter>
    	</entity>
    </fetch>


    Changing the value in the condition changes the results as you'd expect.

    A word of warning though - the condition here is doing a string compare and not a numeric compare. You could do the same comparison with Name:

    <condition attribute="name" value="B" operator="gt"/>

    would bring back accounts whose name is "B ", "B1", anything that doesn't start with A.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

      Aiden

  • Community Member Profile Picture
    on at

    Hi Aiden,

    thats exactly what I need. Thanks a lot !

    I dont have my laptop with me so I couldnt test it right a way.

  • Suggested answer
    Divyang Shukla Profile Picture
    355 on at

    No it is not possible, As zip code is String we cannot filter using gt or lt. But we can use below listed operators to filter.

    • Equals
    • Does not equal
    • Contains
    • Does not contains
    • Beings with
    • Does not Being with
    • Ends with
    • Does not End with
    • Contains Data
    • Does not Contains Data
  • Aiden Kaskela Profile Picture
    19,696 on at

    Divyang,

    Through Fetch XML you can use gt and lt operators on string fields but they do sting comparisons, not numeric. Suppose you had a string field with values:

    100

    100000

    20000

    5000

    9

    If you queried for value gt 40000, you would get back 5000 and 9.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans