Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

unable to change flag color on account

Posted on by 130

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 .

*This post is locked for comments

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: unable to change flag color on account

    Hi,

    Please elaborarte the problem you faced, have you tried to debug it? Which line is causing the problem.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans