Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Column Image in View

Posted on by 75

Hi,

I am trying to get an image to appear in a column of a view depending on the two option set selection (yes/no)

I created a new png web resource for each icon, a thumbs up and a thumbs down.

I created a javascript webresource as well:

function displayIconTooltip(rowData, userLCID) {
var str = JSON.parse(rowData);
var col_data = str.new_compliant_Value;
var imgName = "";
var tooltip = "{" + col_data +"}";

switch (col_data) {
case 1:
imgName = "new_ThumbsUp";
tooltip = "Good";
break;
case 2:
imgName = "new_ThumbsDown";
tooltip = "Bad";
break;
default:
imgName = "";
tooltip = "";
break;
}
var resultarray = [imgName, tooltip];
return resultarray;
}

In the view I changed the properties of the column to the javascript webresource and function.

I saved everything and published all.

When I run it though, I get nothing.  No errors and no icons?

Did I do something incorrect?  How does the javascript cases work?

Thanks,

Terry

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Column Image in View

    HI Terry,

    Did you change the option set value as we discussed above and try again? If there is any new situation or problem, please feel free to communicate with us.

    Best Regards,

    Leo

  • mattw112 Profile Picture
    mattw112 75 on at
    RE: Column Image in View

    Thanks I have tried to change things to reflect my actual situation, icon names, option set name..

    I like your integer idea though I've come across that with flow before.

    Thanks,

    Terry

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Column Image in View

    Hi,

    I come across this before and the problem was in the value returned in col_data. For two options it s different value. Can't remember now the exact change but if you debug and check the value of col_data, you should be able to figure out.

    Hope this helps.

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Column Image in View

    Hi partner,

    Yes, you should change the code according to your actual situation.

    And you could also add a step to transfer "col_data" to int with "parseInt()".

    Best Regards,

    Leo

  • mattw112 Profile Picture
    mattw112 75 on at
    RE: Column Image in View

    Thanks icons are fine, function name is good, JS resource is good...

    Is it that this is a two option set?  is "0" and "1" correct (yes my cases are 0 and 1, not 1 and 2)

    Is the function correct for that?

    Thanks,

    Terry

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Column Image in View

    Hi partner,

    1. Check your image files sizes, 16x16 is recommended.

    2. Check if you add your js resource into the view.

    3. Check if you add this function to the view properties.

    You could refer to the doc sample step by step and try again.

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/customize/display-custom-icons-instead

    Hope it helps.

    Best Regards,

    Leo

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans