web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get the child account under parent account from database

(0) ShareShare
ReportReport
Posted on by 958

This is to ask that how i get the related child account under parent account from database using odata query.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi Shakti,

    I am Curious to know why you want to Use Odata? It is deprecated.

    use webapi instead ,you just have to expand the navigation from parent account to child accounts by giving the relationship name : msdn.microsoft.com/.../gg334767.aspx

  • Shakti Singh Rajput Profile Picture
    958 on at

    Basically what i want to do, i want to show the child account address1_city/Latitude/Longitude under the parent account on bing map with multiple pushpins. I Also find an code of that but it not works.

    This is the link of that code:- http://himbap.com/blog/?p=1837

    So can you please help to resolve this problem.

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi Shakti,

    It should work you just have to replace odata query with WebApi and it should be okay using the link i gave you above.

  • Shakti Singh Rajput Profile Picture
    958 on at

    This is the code that i used and in this code first i make an web resource of Rest.SDK,js file

    and then i make an another web resource which code is given below.

    Now, please explain what should i do?

    <html>  

       <head>  

           <script src="../../ClientGlobalContext.js.aspx"></script>  

            <script src="new_/Script/SDK.REST.js" type="text/javascript"></script>

           <title>Show Child Accounts</title>  

           <meta http-equiv="Content-Type" content="text/html; charset=utf-8">  

           <script src="ecn.dev.virtualearth.net/.../mapcontrol.ashx; type="text/javascript"></script>  

           <script type="text/javascript">  

           var map = null;  

           var messageBox = null;  

           var lat = null;  

           var lon = null;  

           var City = null;  

           var AccountName = null;  

           var pushpin = null;  

           var pushpinCollection = new Microsoft.Maps.EntityCollection();  

           var messageBoxCollection = new Microsoft.Maps.EntityCollection();  

          /* document.onreadystatechange = function ()*/

          function loadingmap()      

           {  

               if(document.readyState == "complete")  

               {  

                   //initialise map    

                   getMap();  

                   alert("after get map");

                   //Get child account records    

                   getChildAccounts();  

               }  

           }  

           function getChildAccounts()  

           {  

               //retrieve current entity id    

               var parentaccountId = window.parent.Xrm.Page.data.entity.getId();  

               var entitySchemaName = "Account";  

               //get all child records based on parent customer id    

               var odataQuery = "?$select=Name,Address1_City,Address2_Latitude,Address2_Longitude&" + "$filter=ParentAccountId/Id eq guid'" + parentaccountId + "'";  

               if(typeof (SDK) != "undefined")  

               {  

                   //The retrieveAccountsCallBack function is passed through as the successCallBack.    

                   SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getnotesImagesCallback, function (error)  

                   {  

                       alert(error.message);  

                   }, function () {});  

               }  

               else  

               {  

                   alert("Not able to load REST.SDK library");  

               }  

           }  

           //callback method    

           function getnotesImagesCallback(resultSet)  

           {  

               //initialise message box    

               messageBox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0),  

               {  

                   visible: false  

               });  

               messageBoxCollection.push(messageBox);  

               //Show current account    

               lat = window.parent.Xrm.Page.getAttribute("address2_latitude")  

                   .getValue();  

               lon = window.parent.Xrm.Page.getAttribute("address2_longitude")  

                   .getValue();  

               City = window.parent.Xrm.Page.getAttribute("address1_city")  

                   .getValue();  

               AccountName = window.parent.Xrm.Page.getAttribute("name")  

                   .getValue();  

               pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, lon));  

               pushpin.Description = AccountName + ", " + City;  

               //show message box on mouse move    

               Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessagebox);  

               //remove message box on mouse lost    

               Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebox);  

               pushpinCollection.push(pushpin);  

               //add collection to map    

               map.entities.push(pushpinCollection);  

               map.entities.push(messageBoxCollection);  

               if(resultSet.length > 0)  

               {  

                   TotalImages = resultSet.length;  

                   for(i = 0; i < resultSet.length; i++)  

                   {  

                       lat = resultSet[i].Address1_Latitude;  

                       lon = resultSet[i].Address1_Longitude;  

                       City = resultSet[i].Address1_City;  

                       AccountName = resultSet[i].Name;  

                       pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, lon));  

                       pushpin.Description = AccountName + ", " + City;  

                       //show message box on move move    

                       Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessagebox);  

                       //remove message box on mouse lost    

                       Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebox);  

                       pushpinCollection.push(pushpin);  

                   }  

                   //add collection to map    

                   map.entities.push(pushpinCollection);  

                   map.entities.push(messageBoxCollection);  

               }  

           }  

           function displaymessagebox(e)  

           {  

               messageBox.setOptions(  

               {  

                   description: e.target.Description,  

                   visible: true,  

                   offset: new Microsoft.Maps.Point(0, 25)  

               });  

               messageBox.setLocation(e.target.getLocation());  

           }  

           function hidemessagebox(e)  

           {  

               messageBox.setOptions(  

               {  

                   visible: false  

               });  

           }  

           function getMap()  

           {  

               map = new Microsoft.Maps.Map(document.getElementById('bingMaps'),  

               {  

                   credentials: 'Aq3qdVTUDrWUuklMkomP_2gZqCyzrw_E9vgnD7cOwuGmcvyV2qI2BCIMr_1W8fxP',  

                   center: new Microsoft.Maps.Location(41.956690, -103.137798),  

                   mapTypeId: Microsoft.Maps.MapTypeId.road,  

                   zoom: 10  

               });  

           }  

           </script>  

           <script type='text/javascript' src='www.bing.com/.../mapcontrol;callback=loadingmap' async defer></script>

       </head>  

       <body onload="loadingmap()">  

           <div id="bingMaps" style="width: 600px; height: 500px; position: relative;"></div>  

       </body>  

    </html>  

  • Shakti Singh Rajput Profile Picture
    958 on at

    I don't know hoe to use web api

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans