1

Is there any way to change the icons of the cases created in Dynamics according to predefined condition? Example I want different icons for the cases based on their priority.

enter image description here

Community
  • 1
  • 1
Apurva Yadav
  • 65
  • 1
  • 6

1 Answers1

0

That icon is a placeholder for uploading image to be record specific. Either default entity image icon can be showed or we can upload any image by clicking that icon in entity record level. It will be stored in entityimage attribute of each record. Read more

What you want is uploading image dynamically based on record field value, may be a webresource icon to that entityimage everytime when update happens from a plugin. Refer this code sample:

string m_statusImageRed = @"C:\\Images\\Incident\\status_red.jpg";
string m_statusImageGrey = @"C:\\Images\\Incident\\status_grey.jpg";

if(entity.Attributes.Contains("statecode"))
    {    
        OptionSetValue stateCodeValue = entity.Attributes["statecode"] as OptionSetValue;
        byte[] imageBytes = null;

        switch (stateCodeValue.Value.ToString())
        {       
            case "0": // active
            if (File.Exists(m_statusImageRed))
            {
                imageBytes = File.ReadAllBytes(m_statusImageRed);
                entity.Attributes["entityimage"] = imageBytes;
            }

            break;

            case "1": // resolved
            if (File.Exists(m_statusImageGrey))
            {
                imageBytes = File.ReadAllBytes(m_statusImageGrey);
                entity.Attributes["entityimage"] = imageBytes;
            }

            break;
       }

       service.Update(entity);
    }

Reference