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: Create a html page and show the
accounts mark red color font for city equal to Dallas show in left navigation
form?
Requirements: JavaScript and HTML
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 chooses 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
Write a HTML
Code and place it in web resource
<html>
<head>
<title></title>
</head>
<body>
<!-- vid is used to acces html element in the
javaScript context -->
<div id="AccountNames">
<h1>Accounts</h1>
</div>
<script>
//
var list
= document.getElementById("AccountNames");
// to access the
data from parent html page
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"];
// to
create html element
var items = document.createElement("p");
// adding text content to items
items.textContent = name;
if (address1_city != null) {
if (address1_city.toLowerCase() == "dallas") {
items.style.color =
"red";
}
}
// append child data to parent data
list.appendChild(items);
}
},
function
(error) {
Xrm.Utility.alertDialog(error.message);
}
);
</script>
</body>
</html><html>
<head>
<title></title>
</head>
<body>
<!-- vid is used to acces html element in the
javaScript context -->
<div id="AccountNames">
<h1>Accounts</h1>
</div>
<script>
//
var list
= document.getElementById("AccountNames");
// to access the
data from parent html page
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"];
// to
create html element
var items = document.createElement("p");
// adding text content to items
items.textContent = name;
if (address1_city != null) {
if (address1_city.toLowerCase() == "dallas") {
items.style.color =
"red";
}
}
// append child data to parent data
list.appendChild(items);
}
},
function
(error) {
Xrm.Utility.alertDialog(error.message);
}
);
</script>
</body>
</html>
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