Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

JavaScript Icon not working in CRM Views

(0) ShareShare
ReportReport
Posted on by 60

Good day and thank you for your interest.

I am looking to implement Icons on CRM Views and CRM Dashboards. I followed the Microsoft documentation found HERE which have sample JS code for this requirement. For my scenario, I simplfied the code but I am still getting an error on when the icon is rendered in the browser. Code is pasted at the botton,

ICON ERROR:

JSIcon.PNG

CODE: 

function displayIconTooltip(rowData, userLCID) {      
    var str = JSON.parse(rowData);  
    var coldata = str.cr66c_rank_Value;  
    var imgName = "";    
    switch (parseInt(coldata,10)) {
        case 1:  
            imgName = "highpriority16svg";    
            break;  

        case 2:  
            imgName = "mediumpriority16svg";  
            break;  

        case 3:  
            imgName = "lowpriority16svg";    
            break;  

        default:  
            imgName = "";    
            break;  
    }  
    var resultarray = [imgName];  
    return resultarray;  
}

Any help on this would be greatly appreciated. Thank you and best regards.

- Arslan

  • Suggested answer
    Arslan001 Profile Picture
    Arslan001 60 on at
    RE: JavaScript Icon not working in CRM Views

    Thank you Tamilarasu.

    It is working perfectly. I was using the Display name of the web resource as opposed to the logical name of the web resource. For me it worked with the logical resource. Thank you again, appreciate your help.

  • Verified answer
    RE: JavaScript Icon not working in CRM Views

    function addIconToView(rowData, userLCID) {
        var data = JSON.parse(rowData);
        var approve = data.comp_approve_Value;
        var imgTooltip = "";
        var imgWebResource = "";
        switch (approve) {
            case 1:
                imgWebResource = "comp_imgg";
                imgTooltip = approve;
                break;
            default:
                imgWebResource = "comp_imgg";
                imgTooltip = approve;
                break;
        }
        return [imgWebResource, imgTooltip];
    }  

    pastedimage1667213304601v1.png

    The above code works perfectly fine for me.

    Try giving tooltip for that image

    Thanks,

    Tamilarasu

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans