Hi All
The requirement is :
There will have three case c1, c2, c3 the color of the flag willl all have red color .
then associated account of the cases will be also have the red color flag on it .
code for set flag color on case :
<html><head>
<script src="ajax.googleapis.com/.../jquery.min.js"></script>
<script src="maxcdn.bootstrapcdn.com/.../bootstrap.min.js"></script>
<link rel="stylesheet" href="maxcdn.bootstrapcdn.com/.../bootstrap.min.css">
<script>
$( document ).ready(function() {
alert( "ready!" );
var value =window.parent.Xrm.Page.getAttribute('new_healthreport').getValue();
//alert(value);
if (value =="null" || value ==0){
document.getElementById("abc").style.color = "blue";
//alert("blue");
window.parent.Xrm.Page.getAttribute('new_flagcolor').setValue("Blue");
}
else if (value ==1 || value < 5) {
//alert("1");
document.getElementById("abc").style.color = "red";
//alert("red");
window.parent.Xrm.Page.getAttribute('new_flagcolor').setValue("Red");
}
else if (value == 5 || value < 10){
document.getElementById("abc").style.color = "orange";
//alert("orange");
window.parent.Xrm.Page.getAttribute('new_flagcolor').setValue("Orange");
}
else if (value == 10 || value < 15){
document.getElementById("abc").style.color = "green";
//alert("green");
window.parent.Xrm.Page.getAttribute('new_flagcolor').setValue("Green");
}
else if ( value >= 15){
document.getElementById("abc").style.color = "yellow";
//alert("yellow");
window.parent.Xrm.Page.getAttribute('new_flagcolor').setValue("Yellow");
}
});
</script>
<style>
.orange {
color: orange;
font-size: 24;
}
.blue {
color: blue;
font-size: 24;
}
.green {
color: green;
font-size: 24;
}
.red{
color: red;
font-size: 24;
}
.yellow{
color: yellow;
font-size: 24;
</style>
<meta><meta><meta><meta><meta><meta><meta><meta><meta><meta><meta><meta><meta><meta><meta><meta></head>
<body style="overflow-wrap: break-word;">
<p id="abc">âš‘</p>
</body></html>
Code for ghet reclate account :
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/incidents?$select=_new_caseaccid_value&$expand=new_asdfId($select=name,new_health,new_newflagcolour)&$count=true", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
var recordCount = results["@odata.count"];
for (var i = 0; i < results.value.length; i++) {
var _new_caseaccid_value = results.value[i]["_new_caseaccid_value"];
var _new_caseaccid_value_formatted = results.value[i]["_new_caseaccid_value@OData.Community.Display.V1.FormattedValue"];
var _new_caseaccid_value_lookuplogicalname = results.value[i]["_new_caseaccid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
//Use @odata.nextLink to query resulting related records
var new_asdfId_NextLink = results.value[i]["new_asdfId@odata.nextLink"];
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
Thanks .