Add Custom Icons and ToolTip to Dynamics 365 Columns in Views

By | December 9, 2016

Introduction:

When we have visual elements to support the data, our analysis becomes relatively simple. With Dynamics 365 we can add custom icon and tooltips to the fields in Views. We can add it using the JavaScript through Web resource.

Let’s see how we can add custom icon and tooltip to columns in views:

Suppose I have a custom field “Approved” with two options, on the Account.

For the option “Yes” with tooltip “Approved” – I want the icon to be:

ok

For the option “No” with tooltip “Not Approved” – I want the icon to be:

notok

Follow the steps below to achieve this:

  1. Dynamics CRM usually resizes the icons, so get the icons in 16 x 16 dimension.
  2. After getting the icons in the size as mentioned above, add 2 Web resources “new_Approved” & “new_NotApproved” icons to webresource in Dynamics CRM.
  3. Add the below Javascript webresource “new_SetIconAndTooltip.js” in Dynamics CRM:
function getRowInfo(rowVal, userlcid) {
debugger;

var imageName = "";
var tooltipValue = "";
var resultarray = null;

try {

//get the row Info
var row = JSON.parse(rowVal);

//get the Value of Custom Field (Column)
var rdata = row.new_approved_Value;
//If yes then set Approved icon and tooltip
if (rdata == true) {

imageName = "new_Approved";
tooltipValue = "Approved";
} //If No then set Approved icon and tooltip
else {

imageName = "new_NotApproved";
tooltipValue = "Not Approved";

}

resultarray = [imageName, tooltipValue];
} catch (e) {

//Handle Error
}


return resultarray;
}

As seen in the code, the above function takes 2 parameters.

rowval: Row Information

userlcid: User Local Identifier which can be used for language information for the Tooltip, as per requirement.

After following the above steps, let’s explore how to attach the above script to the specific view.

  1. Navigate to Settings → Customizations → Account → Views
  2. Open the “Active Accounts” view.
  3. Select the “Approved” column and click Change Properties. After this you will reach to “Change Column Properties” as seen in the below screenshot:

34. In the Web Resource, select the uploaded script and enter the function name.

5. Once you’re done, click Ok. Then save and publish the changes. Now navigate to “Active Accounts” view in Dynamics CRM you will see the below screen:

5

Conclusion:

This nifty feature will enable you to add any indicator icons in the “Views” for visually distinguishing data in Dynamics 365.

To stay updated with Dynamics 365 new features, visit Inogic Blogs!

 

0 thoughts on “Add Custom Icons and ToolTip to Dynamics 365 Columns in Views

  1. Ravikumar Yerra

    Hi
    i want to show Icons in grid view column based on other column option set value same as like in CASE entity ..

    Ex. i have A(single text area type field) column here show icons based on B (option set) field . Please let me know

    Reply
    1. inogic Post author

      Hi,

      To show the icons in grid view columns you would first need to add web resource for the icons.
      You would need to add the javascript web resource on view column (i.e. single line text area field) and the function name.
      I tried implementing the same scenario at my end and could achieve it successfully by following below script. Consider my icon web resource to be “Green.png” and “Red.png”. And also, the optionset field named “Process Status” with option values as 1 and 2.
      Script:
      public displayIconTooltip(rowData) {
      //Local variables
      let functionName: string = “displayIconTooltip”;
      let row: any;
      let processStatus: any;
      let imgName: string = “”;
      let tooltip: string = “”;
      let resultarray;
      try {
      //Get the row data
      row = JSON.parse(rowData);
      //Get the value of process status optionset field
      processStatus = row.new_processstatus_Value;
      //Check if value equals On-Hold
      if (processStatus == 1) {
      imgName = “new_/Green.png”;
      tooltip = “On-Hold”;
      }
      //Check if value equals Completed
      else if (processStatus == 2) {
      imgName = “new_/Red.png”;
      tooltip = “Completed”;
      }
      else {
      imgName = “”;
      tooltip = “”;
      }

      resultarray = [imgName, tooltip];
      }
      catch (ex) {
      }
      return resultarray;
      }

      Thanks!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *