Add Icons to View columns in Dynamics 365

Sometimes it's better to give the user sort of visualization of the values, it makes the user feel the value of a certain status.
For Instance, We want to display an icon for the priority of the cases in the CRM, below is the process for it,
First thing first, you have to upload the icons into the CRM as Image web resources, and its recommended to resize the images to 16*16.
Then create a JavaScript web resource and add you code, below is my code for my example,
function RowInfo(rowVal, userlcid) {
var imageName = "";
var tooltipValue = "";
var resultarray = null;
 
try {
 
var row = JSON.parse(rowVal);
var rowValue = row.prioritycode;

switch(rowValue){
 case 'Critical':
  imageName = "ans_critical16";
  tooltipValue = "Critical";
  break;
 case 'High':
  imageName = "ans_high16";
  tooltipValue = "High Priority";
  break;
 case 'Normal':
  imageName = "ans_normal16";
  tooltipValue = "Normal Priority";
  break;
 case 'Low':
  imageName = "ans_low16";
  tooltipValue = "Low Priority";
  break;
 default:
  break;

}
 
resultarray = [imageName, tooltipValue];

} catch (e) {

}
 
 
return resultarray;
}


Then choose the view you want to add the icons to, and make sure to add the field you want to add the icons based on it to the view, in my example i will add icons to the active cases view in the Case entity based on the priority.
Click on the column you want, and click Change Properties.
Add your JS web resource and your function, click ok, save and publish.

Output:

Thanks to Inogic.
Thanks!

Comments

Popular Posts