SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
Show child accounts on Bing Maps under
Parent
In this article we are going to demonstrate how we can add multiple pushpins in Bing Maps based on the
latitude and longitude. First we need to make sure address1_latitude and address1_longitude should
be added under account form and should be filled for all account records based on their address.
Requirement: Let’s say we have requirement to show all the child accounts (sub accounts) as pushpins
on map under parent account and show their name, city when user will hover on pushpin.
Solution: We can simply develop an html web resource where we can use Bing Maps AJAX control to
show pushpins for child account based on the latitude or longitude values. We can implement this in
three steps:
• Get Bing Maps API
• Need to retrieve all child accounts for current account
• Add pushpins to Bing Maps based on latitude and longitude returned from child accounts
So Let’s follow below steps
• To get Bing Maps key, you can follow instruction here to get it.
• We can create a new solution or can do this customization in base solution, (If you are new to solution,
please refer our earlier posts to create solution).
• Let’s first upload REST.SDK.js to your solution, we can use retrievemultiple method under this library
to get child records and use below settings (Note: you can get this file under
SampleCodeJSRESTEndpointJavaScriptRESTAssociateDisassociateJavaScriptRESTAssociateDisassociat
eScripts) under your CRM SDK folder, if you don’t have CRM SDK download and extract it first.
Note: We have used him prefix in our publisher it could be new for you if you are not
using specific prefix.
• Create new HTML web resource and use below details.
 Use below code for this html web resource
1. <html>
2.
3. <head>
4. <script src="../../ClientGlobalContext.js.aspx"></script>
5. <script src="../Script/SDK.REST.js" type="text/javascript"></script>
6. <title>Show Child Accounts</title>
7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8. <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" type
="text/javascript"></script>
9. <script type="text/javascript">
10. var map = null;
11. var messageBox = null;
12. var lat = null;
13. var lon = null;
14. var City = null;
15. var AccountName = null;
16. var pushpin = null;
17.
18. var pushpinCollection = new Microsoft.Maps.EntityCollection();
19. var messageBoxCollection = new Microsoft.Maps.EntityCollection();
20.
21. document.onreadystatechange = function() {
22. if (document.readyState == "complete") {
23. //initialise map
24. getMap();
25. //Get child account records
26. getChildAccounts();
27. }
28. }
29.
30. function getChildAccounts() {
31. //retrieve current entity id
32. var parentaccountId = window.parent.Xrm.Page.data.entity.getId();
33. var entitySchemaName = "Account";
34. //get all child records based on parent customer id
35. var odataQuery = "?$select=Name,Address1_City,Address1_Latitude,Address1_Lo
ngitude&" +
36. "$filter=ParentAccountId/Id eq guid'" + parentaccountId + "'";
37.
38. if (typeof(SDK) != "undefined") {
39. //The retrieveAccountsCallBack function is passed through as the succes
sCallBack.
40. SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getnotes
ImagesCallback, function(error) {
41. alert(error.message);
42. }, function() {});
43. } else {
44. alert("Not able to load REST.SDK library");
45. }
46.
47. }
48. //callback method
49. function getnotesImagesCallback(resultSet) {
50.
51. //initialise message box
52. messageBox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0),
{
53. visible: false
54. });
55. messageBoxCollection.push(messageBox);
56.
57. //Show current account
58. lat = window.parent.Xrm.Page.getAttribute("address1_latitude").getValue();
59. lon = window.parent.Xrm.Page.getAttribute("address1_longitude").getValue();
60. City = window.parent.Xrm.Page.getAttribute("address1_city").getValue();
61. AccountName = window.parent.Xrm.Page.getAttribute("name").getValue();
62.
63. pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, lon))
;
64. pushpin.Description = AccountName + ", " + City;
65. //show message box on mouse move
66. Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessagebox);
67. //remove message box on mouse lost
68. Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebox);
69. pushpinCollection.push(pushpin);
70.
71. //add collection to map
72. map.entities.push(pushpinCollection);
73. map.entities.push(messageBoxCollection);
74.
75. if (resultSet.length > 0) {
76. TotalImages = resultSet.length;
77. for (i = 0; i < resultSet.length; i++) {
78. lat = resultSet[i].Address1_Latitude;
79. lon = resultSet[i].Address1_Longitude;
80. City = resultSet[i].Address1_City;
81. AccountName = resultSet[i].Name;
82.
83. pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(la
t, lon));
84. pushpin.Description = AccountName + ", " + City;
85.
86. //show message box on move move
87. Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessa
gebox);
88. //remove message box on mouse lost
89. Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebo
x);
90. pushpinCollection.push(pushpin);
91.
92. }
93. //add collection to map
94. map.entities.push(pushpinCollection);
95. map.entities.push(messageBoxCollection);
96. }
97.
98. }
99.
100. function displaymessagebox(e) {
101. messageBox.setOptions({
102. description: e.target.Description,
103. visible: true,
104. offset: new Microsoft.Maps.Point(0, 25)
105. });
106. messageBox.setLocation(e.target.getLocation());
107. }
108.
109. function hidemessagebox(e) {
110. messageBox.setOptions({
111. visible: false
112. });
113. }
114.
115. function getMap() {
116. map = new Microsoft.Maps.Map(document.getElementById('bingMaps'), {
117. credentials: 'Your BingMaps key',
118. center: new Microsoft.Maps.Location(41.956690, -103.137798),
119. mapTypeId: Microsoft.Maps.MapTypeId.road,
120. zoom: 10
121. });
122. }
123. </script>
124. </head>
125.
126. <body>
127. <div id="bingMaps" style="width: 600px; height: 500px; position: relative;">
</div>
128. </body>
129.
130. </html>
 Save and publish your web resource and place this web resource to account form
by navigating Insert ->Web Resource under form editor.
 Save and publish form and open any account record, if current account will have
any child record it will show pushpins for child accounts otherwise it will just show
current account record pushpin.
References: BingMaps SDK
HIMBAP | Need any help in Microsoft Dynamics CRM Contact US !!

Weitere ähnliche Inhalte

Kürzlich hochgeladen

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Kürzlich hochgeladen (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Show child accounts on bing maps under parent

  • 1. Show child accounts on Bing Maps under Parent In this article we are going to demonstrate how we can add multiple pushpins in Bing Maps based on the latitude and longitude. First we need to make sure address1_latitude and address1_longitude should be added under account form and should be filled for all account records based on their address. Requirement: Let’s say we have requirement to show all the child accounts (sub accounts) as pushpins on map under parent account and show their name, city when user will hover on pushpin. Solution: We can simply develop an html web resource where we can use Bing Maps AJAX control to show pushpins for child account based on the latitude or longitude values. We can implement this in three steps: • Get Bing Maps API • Need to retrieve all child accounts for current account • Add pushpins to Bing Maps based on latitude and longitude returned from child accounts So Let’s follow below steps • To get Bing Maps key, you can follow instruction here to get it. • We can create a new solution or can do this customization in base solution, (If you are new to solution, please refer our earlier posts to create solution). • Let’s first upload REST.SDK.js to your solution, we can use retrievemultiple method under this library to get child records and use below settings (Note: you can get this file under SampleCodeJSRESTEndpointJavaScriptRESTAssociateDisassociateJavaScriptRESTAssociateDisassociat eScripts) under your CRM SDK folder, if you don’t have CRM SDK download and extract it first. Note: We have used him prefix in our publisher it could be new for you if you are not using specific prefix. • Create new HTML web resource and use below details.
  • 2.  Use below code for this html web resource 1. <html> 2. 3. <head> 4. <script src="../../ClientGlobalContext.js.aspx"></script> 5. <script src="../Script/SDK.REST.js" type="text/javascript"></script> 6. <title>Show Child Accounts</title> 7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 8. <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" type ="text/javascript"></script> 9. <script type="text/javascript"> 10. var map = null; 11. var messageBox = null; 12. var lat = null; 13. var lon = null; 14. var City = null; 15. var AccountName = null; 16. var pushpin = null; 17. 18. var pushpinCollection = new Microsoft.Maps.EntityCollection(); 19. var messageBoxCollection = new Microsoft.Maps.EntityCollection(); 20. 21. document.onreadystatechange = function() { 22. if (document.readyState == "complete") { 23. //initialise map 24. getMap(); 25. //Get child account records 26. getChildAccounts(); 27. } 28. } 29. 30. function getChildAccounts() { 31. //retrieve current entity id 32. var parentaccountId = window.parent.Xrm.Page.data.entity.getId(); 33. var entitySchemaName = "Account"; 34. //get all child records based on parent customer id 35. var odataQuery = "?$select=Name,Address1_City,Address1_Latitude,Address1_Lo ngitude&" + 36. "$filter=ParentAccountId/Id eq guid'" + parentaccountId + "'"; 37. 38. if (typeof(SDK) != "undefined") { 39. //The retrieveAccountsCallBack function is passed through as the succes sCallBack. 40. SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getnotes ImagesCallback, function(error) { 41. alert(error.message); 42. }, function() {});
  • 3. 43. } else { 44. alert("Not able to load REST.SDK library"); 45. } 46. 47. } 48. //callback method 49. function getnotesImagesCallback(resultSet) { 50. 51. //initialise message box 52. messageBox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { 53. visible: false 54. }); 55. messageBoxCollection.push(messageBox); 56. 57. //Show current account 58. lat = window.parent.Xrm.Page.getAttribute("address1_latitude").getValue(); 59. lon = window.parent.Xrm.Page.getAttribute("address1_longitude").getValue(); 60. City = window.parent.Xrm.Page.getAttribute("address1_city").getValue(); 61. AccountName = window.parent.Xrm.Page.getAttribute("name").getValue(); 62. 63. pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, lon)) ; 64. pushpin.Description = AccountName + ", " + City; 65. //show message box on mouse move 66. Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessagebox); 67. //remove message box on mouse lost 68. Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebox); 69. pushpinCollection.push(pushpin); 70. 71. //add collection to map 72. map.entities.push(pushpinCollection); 73. map.entities.push(messageBoxCollection); 74. 75. if (resultSet.length > 0) { 76. TotalImages = resultSet.length; 77. for (i = 0; i < resultSet.length; i++) { 78. lat = resultSet[i].Address1_Latitude; 79. lon = resultSet[i].Address1_Longitude; 80. City = resultSet[i].Address1_City; 81. AccountName = resultSet[i].Name; 82. 83. pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(la t, lon)); 84. pushpin.Description = AccountName + ", " + City; 85. 86. //show message box on move move 87. Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessa gebox); 88. //remove message box on mouse lost 89. Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebo x); 90. pushpinCollection.push(pushpin); 91. 92. } 93. //add collection to map 94. map.entities.push(pushpinCollection); 95. map.entities.push(messageBoxCollection);
  • 4. 96. } 97. 98. } 99. 100. function displaymessagebox(e) { 101. messageBox.setOptions({ 102. description: e.target.Description, 103. visible: true, 104. offset: new Microsoft.Maps.Point(0, 25) 105. }); 106. messageBox.setLocation(e.target.getLocation()); 107. } 108. 109. function hidemessagebox(e) { 110. messageBox.setOptions({ 111. visible: false 112. }); 113. } 114. 115. function getMap() { 116. map = new Microsoft.Maps.Map(document.getElementById('bingMaps'), { 117. credentials: 'Your BingMaps key', 118. center: new Microsoft.Maps.Location(41.956690, -103.137798), 119. mapTypeId: Microsoft.Maps.MapTypeId.road, 120. zoom: 10 121. }); 122. } 123. </script> 124. </head> 125. 126. <body> 127. <div id="bingMaps" style="width: 600px; height: 500px; position: relative;"> </div> 128. </body> 129. 130. </html>  Save and publish your web resource and place this web resource to account form by navigating Insert ->Web Resource under form editor.  Save and publish form and open any account record, if current account will have any child record it will show pushpins for child accounts otherwise it will just show current account record pushpin.
  • 5. References: BingMaps SDK HIMBAP | Need any help in Microsoft Dynamics CRM Contact US !!