Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Retrieve 1:N relationships with javascript dynamics 365 crm

Posted on by Microsoft Employee

For example, I have a Case and some activities, which are related. How can I get the information from this activities, when case form is onload?

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve 1:N relationships with javascript dynamics 365 crm

    Hi Lyubo,

    great!

    Could you please mark the answers as verified? Thanks a lot!

    Regards,

    Karan

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve 1:N relationships with javascript dynamics 365 crm

    I did it because of your answers. I am really thankful to all of you.

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Retrieve 1:N relationships with javascript dynamics 365 crm

    Hi,

    See the link below.

    msdn.microsoft.com/.../gg334208.aspx

    Hope this helps.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve 1:N relationships with javascript dynamics 365 crm

    Use CRMRestBuilder tool to get activities on case:

    github.com/.../releases

    var req = new XMLHttpRequest();

    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/activitypointers?$select=actualend,actualstart,_regardingobjectid_value,scheduledend,scheduledstart,senton,statecode,statuscode&$filter=_regardingobjectid_value eq'" +Xrm.Page.data.entity.getId()+"'", true);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

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

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

    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 200) {

               var results = JSON.parse(this.response);

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

                   var actualend = results.value[i]["actualend"];

                   var actualstart = results.value[i]["actualstart"];

                   var _regardingobjectid_value = results.value[i]["_regardingobjectid_value"];

                   var _regardingobjectid_value_formatted = results.value[i]["_regardingobjectid_value@OData.Community.Display.V1.FormattedValue"];

                   var _regardingobjectid_value_lookuplogicalname = results.value[i]["_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];

                   var scheduledend = results.value[i]["scheduledend"];

                   var scheduledstart = results.value[i]["scheduledstart"];

                   var senton = results.value[i]["senton"];

                   var statecode = results.value[i]["statecode"];

                   var statecode_formatted = results.value[i]["statecode@OData.Community.Display.V1.FormattedValue"];

                   var statuscode = results.value[i]["statuscode"];

               }

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send();

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve 1:N relationships with javascript dynamics 365 crm

    It will be also helpful if you can give me some more detail on that what you want to do.

    Do you need to aggregate the records? Some status of the records? Waht exactly is the target?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve 1:N relationships with javascript dynamics 365 crm

    Check this out:

    msdn.microsoft.com/.../gg334427(v=crm.7).aspx

    Regards,

    Karan

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans