![](https://venkatasubbaraopolisetty.files.wordpress.com/2022/09/66.jpg?w=871)
Introduction:
During certain scenarios we must build a custom html to show data from Dynamics CRM as per customer requirement. As an example, a separate tab was shown on contact form to show selected contact’s Account Address details in the below
Step 1:
Login to the required environment and select required solution [Contact Customizations Solution in this case] as shown in the below figure.
![](https://venkatasubbaraopolisetty.files.wordpress.com/2022/09/working-with-a-html-webresource-in-dynamics-crm-figure1.jpg?w=1024)
Step 2:
After Step 1, create a Webresource of type html and upload an empty html as shown in the below figure.
![](https://venkatasubbaraopolisetty.files.wordpress.com/2022/09/working-with-a-html-webresource-in-dynamics-crm-figure2.jpg?w=1024)
Step 3:
After Step 2, open html and write the below code
<html>
<head>
http://ClientGlobalContext.js.aspx
<script type=”text/javascript”>
function onLoad() {
var contactGUID = parent.Xrm.Page.data.entity.getId().replace(“{“,””).replace(“}”,””);;
Xrm.WebApi.retrieveRecord(“contact”, contactGUID, “?$select=fullname&$expand=account_primary_contact($select=address1_line1)”).then(
function success(result) {
console.log(“Retrieved values of Account : Address: ” + result.account_primary_contact[0].address1_line1);
document.getElementById(“contactpara”).innerHTML = “Retrieved values of Account : Address: “+result.account_primary_contact[0].address1_line1;
// perform operations on record retrieval
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
}
</script>
</head>
<body onload=”onLoad()”>
This is a Html Web resource<br>
<p id=”contactpara”></p>
</body>
</html>
as shown in the below figure.
![](https://venkatasubbaraopolisetty.files.wordpress.com/2022/09/working-with-a-html-webresource-in-dynamics-crm-figure3.jpg?w=640)
Step 4:
After Step 3, go to the contact form and create a tab and section and in that add this Webresource save it and publish it as shown in the below figure
![](https://venkatasubbaraopolisetty.files.wordpress.com/2022/09/working-with-a-html-webresource-in-dynamics-crm-figure4.jpg?w=640)
Step 5:
After Step 4, open any contact record and select Custom Html Tab and observe Selected contact related Account Address information displayed in contact record as shown in the below figure.
![](https://venkatasubbaraopolisetty.files.wordpress.com/2022/09/working-with-a-html-webresource-in-dynamics-crm-figure5.jpg?w=640)
Note:
- Make sure to publish all customizations and upload html file.
- Make sure to include ClientGlobalContext.js.aspx script other wise you get an issue with parent.xrm object in code.
Conclusion: In this way, one can easily use html as a Webresource to show contact related information in custom way other than using Forms.
*This post is locked for comments