Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

How to Query Entitlement Product.

(0) ShareShare
ReportReport
Posted on by

Hello, i stumbled with a problem and i hope someone could offer some help.


    I' am aware that the entitlement product is not really an entity but a Relationship, i can create the Entitlement Product in a plugin, using C# with an associate request, no problem there. But i can't find the way to make the equivalent to a QueryExpression in a RelationShip.

The closest thing that i found in the documentation is this link:

docs.microsoft.com/.../gg328149(v=crm.8)

but i'm being unable to translate that in a working query.

I have an entitlement with entitlementid X, what's the correct syntax to get all the entitlement products where entitlementid_value is equal to ID X ?

Thank's in advance,

  • Community Member Profile Picture
    on at
    RE: How to Query Entitlement Product.

    Hi, i have to change the code just a little bit but it finally worked:

    var QEproduct_entitlementproducts_entitlement_entitlementid = "f582dc51-dd4c-e911-a977-002248010929";

                       // Instantiate QueryExpression QEproduct

                       var QEproduct = new QueryExpression("product");

                       QEproduct.Distinct = true;

                       // Add columns to QEproduct.ColumnSet

                       QEproduct.ColumnSet.AddColumns("name", "description");

                       QEproduct.AddOrder("productnumber", OrderType.Ascending);

                       // Add link-entity QEproduct_entitlementproducts

                       var QEproduct_entitlementproducts = QEproduct.AddLink("entitlementproducts", "productid", "productid");

                       // Add link-entity QEproduct_entitlementproducts_entitlement

                       var QEproduct_entitlementproducts_entitlement = QEproduct_entitlementproducts.AddLink("entitlement", "entitlementid", "entitlementid");

                       QEproduct_entitlementproducts_entitlement.EntityAlias = "aa";

                       // Define filter QEproduct_entitlementproducts_entitlement.LinkCriteria

                       QEproduct_entitlementproducts_entitlement.LinkCriteria.AddCondition("entitlementid", ConditionOperator.Equal, QEproduct_entitlementproducts_entitlement_entitlementid);

                       var results = service.RetrieveMultiple(QEproduct);

                        Thank you very much Kokulan.

  • Verified answer
    Kokulan Profile Picture
    18,054 on at
    RE: How to Query Entitlement Product.

    Hi

    Please use the following query to get the products for entitlement

    // Define Condition Values
    var QEproduct_entitlementproducts_entitlement_entitlementid = "f582dc51-dd4c-e911-a977-002248010929";  <--- Replace this with your entitlement ID

    // Instantiate QueryExpression QEproduct
    var QEproduct = new QueryExpression("product");
    QEproduct.Distinct = true;

    // Add columns to QEproduct.ColumnSet
    QEproduct.ColumnSet.AddColumns("name", "productid", "productnumber", "description", "statecode", "productstructure");
    QEproduct.AddOrder("productnumber", OrderType.Ascending);

    // Add link-entity QEproduct_entitlementproducts
    var QEproduct_entitlementproducts = QEproduct.AddLink("entitlementproducts", "productid", "productid");

    // Add link-entity QEproduct_entitlementproducts_entitlement
    var QEproduct_entitlementproducts_entitlement = QEproduct_entitlementproducts.AddLink("entitlement", "entitlementid", "entitlementid");
    QEproduct_entitlementproducts_entitlement.EntityAlias = "aa";

    // Define filter QEproduct_entitlementproducts_entitlement.LinkCriteria
    QEproduct_entitlementproducts_entitlement.LinkCriteria.AddCondition("entitlementid", ConditionOperator.Equal, QEproduct_entitlementproducts_entitlement_entitlementid);

    var results = CrmService.RetrieveMultiple(QEproduct);

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans