Fetch xml with OR condtion for two entities RRS feed

  • Question

  • Hi, All

    our Plugin want to filter crm data based on below condition (fate sql as example)

    select a.* from Opp a, Account b where a.ownerid = 'xxxx' or  (a.parentaccountid=b.accountid and b.location = 'us')

    anybody know how to convert such sql sentence into FetchXML?

    Friday, May 26, 2017 11:20 AM

All replies

  • Hello,

    I'm afraid that at the moment FetchXml doesn't support such filtering. You can apply "or" only between conditions on the same entity.

    Dynamics CRM/Business Solutions MVP
    Read My blog

    Friday, May 26, 2017 12:23 PM
  • looks like the workaroud solution is:

    first step, execute below query:

    select accountid from account where location = 'us'

    Once we get all accountid then, execute below query:

    select * from opp where ownerid = 'xxxx' or parentaccountid in ( all accountid)

    Then, we can get what we want.

    Saturday, May 27, 2017 1:33 AM