Java Script Task 10: Create a html page and show the accounts mark red color font for city equal to dallas show in left navigation form?
User Story: if you click on the html page in the left navigation then show only which accounts with red color font which account having the city name as Dallas.
1) Open CRM Rest Builder and Retrieve the Account entity details such as choose fields as Name and Address1-city
2) Write Java script code and add that code into to Html by using script tag
3) Add This Html code in to web resource
o Here choose Web Resource type as Web Page (HTML)
4) Go to Default solution and choose Client Extension Component
o Under Client Extension choose Site Map
o Open Site Map and choose Area and click on Add button and choose sub area and in URL field choose html web resource name.
1) Open CRM Rest Builder choose conditions and click on Create Request
After Click on Create Request below code is generated
Code:
<html>
<head>
hello
</head>
<body>
<div id="groupOfRecords"></div>
<script>
var groupOfRecords=document.getElementById("groupOfRecords");
parent.Xrm.WebApi.online.retrieveMultipleRecords("account", "?$select=address1_city,name").then(
function success(results)
{
for(var i = 0; i < results.entities.length; i++)
{
var address1_city = results.entities[i]["address1_city"];
var name = results.entities[i]["name"];
//Creating Paragraph element
var groupItem=document.createElement("p");
groupItem.textContent=name;
if(address1_city!=null)
{
if(address1_city.toLowerCase()=="dallas")
{
groupItem.style.color = "red";
}
}
groupOfRecords.appendChild(groupItem);
}
},
function(error)
{
Xrm.Utility.alertDialog(error.message);
}
);
</script>
</body>
</html>
Open web resource and click on New Button
In Type section area choose webpage (HTML) and click on Text editor
After clicking on Text Editor below window will open
Here choose Source and Paste the above code, click on Ok and Publish
Go to Default solution and choose Client Extensionsà SiteMap
If you click on site map below window will open
Here choose area and click on Add button and choose Type as Web Resource
Url: Choose web resource name
Title: Enter user defined name
Click on save and publish
Output:
Comments
Post a Comment