Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

i can't generate primary entity in crmrestbuilder ?

Posted on by 670

i can't generate primary entity in crmrestbuilder please find below screenshot .if anyone know please help me

crmrestbuilder.JPG

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: i can't generate primary entity in crmrestbuilder ?

    Hi,

    You have to pass the Guid of parent record.

    Thanks,

  • account payable Profile Picture
    account payable 670 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    hi Aric Levin

    I cant get the id when Create Request button please find below screenshot

    id-is-not-get.JPG

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    In addition to that you can also refer: missdynamicscrm.blogspot.com.au/.../tips-and-trick-odata-crm-2011-2013.html

    How to use it.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    Hi Sabih,

    I don't have CRM 2013 or your solution installed, but I will try to walk you through it.

    When you go to Settings -> Solutions, you should now see on the Command Bar a button for REST Builder.

    Click on the button, and that will open CRM Rest Builder in a new window/tab.

    - In the Action, select Retrieve Multiple.

    - In the Primary Entity, select the entity of the subgrid on which you want to calculate the items.

    - In the Fields to select, select the fields that you want to return from your query. This will have to include the amount fields for which you want to calculate the totals.

    - In the Filter, add the attribute of the parent record id. For example, if you were on the Invoice record and had a subgrid of Invoice Details, the attribute would be Invoice Id, operator would be Equal and Value would be the Guid of the Invoice. You will need to follow the same logic on your entity and subgrid.

    After you have set all the options, click on the Create Request button. You will see the code in the window, and you can copy the code in your browser. From the sample I just gave you, this is the results output:

    var req = new XMLHttpRequest();

    req.open("GET", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/InvoiceDetailSet?$filter=InvoiceId/Id eq (guid'12345678-9ABC-DEF0-1234-567890ABCDEF')", true);

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           this.onreadystatechange = null;

           if (this.status === 200) {

               var returned = JSON.parse(this.responseText).d;

               var results = returned.results;

               var InvoiceDetailId = results[i].InvoiceDetailId;

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send();

    *********

    After the var results = returned.results line, you can add a for loop to do you calculations:

    var totalAmount = 0;

    for (var i = 0; i < results.length; i++)

    {

      var amount = results[i].new_costinbhd;

      totalAmount += amount;

    }

    Hope this helps you.

    If you get into code error issues, you can add debugger to your lines of code, or click on F12 to open your browser Developer Tools.

    Hope this helps.

  • account payable Profile Picture
    account payable 670 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    hI Mahender and Aric Levin 

    YES IMPORTING TO OUR CRM.please find below screenshot .could you please advise me next step

    SOLUTION-IMPORTED.JPG

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    Hi Sahib,

    Open your CRM application, navigate to Settings->Solutions->Import and then select the managed solution that is there.

    Let us know if you are still facing any issue

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    Did you install the managed solution?

    As Andrew mentioned earlier, don't download the source code, but the managed solution.

    After you downloaded the solution, in CRM go to Settings -> Solutions.

    Click Import, and select the zip file of the CRM Rest Builder managed solution.

    You should be able to use it after that.

    Also, if you have v2.5 installed, uninstall it first.

    Let me know if that helps you out.

  • account payable Profile Picture
    account payable 670 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    Hi Aric Levin ,

    Actually i download CRMRESTBuilder_1_5_0_0_managed but I don't know how to use Rest builder statement for this

    please find below downloaded folder

    crmrestbuilder2.JPG       

    crmrestbuilder2.JPGe

    Please find below my javascript ,I want to use with web api(crmrestbulder) but I don't know how to use in crmrestbuilder .please advise me how to do this

    my java script

    *****************

    function getCostBHDTotal() {

    debugger;

    var costBHDTotal = 0;;

                               // but here I want to use SDK.REST.retrieveMultipleRecords

    function (results) {

    for (var i = 0; i < results.length; i++) {

    var new_costinbhd = results[i].new_costinbhd;

    costBHDTotal += parseInt(new_costinbhd);

    }

    },

    function (error) {

    alert(error.message);

    },

    function () {

    alert(costBHDTotal);

    }

    );

    // alert(costBHDTotal);

    }

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    Sorry, my mistake. No rollups in CRM 2013, only 2015 and above.

    In that case, your best best is use JavaScript with REST Builder.

    Build your Rest statement with Rest Builder to retrieve all child records and sum them up.

    The code that you provided seems fine, except that you did not share your actual query.

    Are you getting errors?

    Also check that you are getting the proper results from the Rest Builder statement.

  • account payable Profile Picture
    account payable 670 on at
    RE: i can't generate primary entity in crmrestbuilder ?

    HI Aric Levin

    there is no rollup field in our crm 2013 on premise. what will do

    rollupfield-is--not-there.JPG

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans