0

I'm quite new to this; but i would like to make a DynamicsCRM report that contains basic info about one opportunity and some info about the reservations that are connected to it.
I've managed to set up Visual Studio to allow me to connect to CRM and fetch one table (f.e. all opportunities).
I'm a bit lost about how to join in the reservations.
One opportunity has several reservations linked to it.
The basic idea is that I have a letter that says "customer x buys a car of this model and his extra options are a,b,c,d"

I can't go to advanced find in CRM to get a query as this kind of one to many relation is not allowed.
I can go in the reservations and export the opportunity information; but that returns one line per reservation.

My guess is that I need to somehow store the ID field of the opportunity in a parameter and then with a second dataset connect to the reservations and import those.

Any tips or help on how to proceed?

Edit, if i do an advanced search for reservations, and add some opportunity fields; it does work in visual studio; but not in CRM (because I do add it to the opportunity entity and not from the reservation entity.

1 Answer 1

0

1:N from opportunity to reservations should be no different than Opportunity to account or customer entities. Use the lookup id on the target entity (e.g. customerid) for the joins.

Replace account below with registration, accountid with registrationid and customerid with the registration lookup id on the opportunity entity.

var fetchxml = "<fetch mapping='logical'>" +
                           "<entity name='opportunity'>" +
                           "<attribute name='opportunityid' />" +
                           "<link-entity name='account' from='accountid' to='customerid'>" +
                           "<attribute name='accountid' />" +
                           "</link-entity>" +
                           "</entity>" +
                           "</fetch>";
1
  • I don't see it; I do need to have an alias name; otherwise I get a wrong fieldname.
    – Brtrnd
    Commented Nov 15, 2016 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.