user2714823
user2714823

Reputation: 605

If-else clause in fetchXml CRM

I want to get data from two tables deal and details. I could make join and fetch data but I couldn't figure out how to link-entity on a condition. In simple terms, I want

if deal.sell is yes:
    fetch details
else:
    fetch deal

The xml below links and fetches some attributes of details , how can I insert the if else clause to this?(if its possible)

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
  <entity name='deal'>
    <attribute name='createdon' />
    <attribute name='statecode' />
    <attribute name='dealsid' />
    <link-entity name='details' from='detailsid' to='deal_detail' >
       <attribute name='description' />
    </link-entity>
  </entity>
</fetch>

Upvotes: 0

Views: 1697

Answers (2)

Daryl
Daryl

Reputation: 18895

You deal with this by having multiple joins, one for each if/else

Using Pesduo code:

 From deal
 Outer Join Details on Deal.Id = Details.Id
 Outer Join Deal on Deal.Id = Deal.ParentDealId

Then you'd do the work on the client side to figure out what you need, and what you don't.

Upvotes: 0

Andrew Butenko
Andrew Butenko

Reputation: 5446

There is no way of doing that using FetchXml. You will have to think about other way of implementing your requirement.

Upvotes: 1

Related Questions