web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Adding Web Resources to Views

(0) ShareShare
ReportReport
Posted on by 365

I am trying to add a webressource into a view to show a yes/no icons marks but it doesn't work i already showing other icons on other columns but is webresources works on boolean fields ?

this is my code

function yesOrNoToolTip(rowData, userLCID) {    
    var str2 = JSON.parse(rowData);
    var col_data2 = str.ans_reserver_Value;
    var imgName2 = "";
    var tooltip2 = "{" + col_data2 +"}";

    switch (col_data2) {
       case 0:
          imgName2 = "tool_no";
          tooltip2 = "No";
          break;
       case 1:
         imgName2 = "tool_yes";
         tooltip2 = "Yes";
         break;
      
    }
    var resultarray2 = [imgName2, tooltip2];
    return resultarray2;
}

*This post is locked for comments

  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    It will work for 2 options Boolean fields as well.

    You have a typo in your code. Correct “str” into “str2” in 2nd line below:

    var str2 = JSON.parse(rowData);

    var col_data2 = str2.ans_reserver_Value;

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    Try with this - Make sure you are using  correct img web-resource path in the red highlighted.

                function yesOrNoToolTip(rowData, userLCID) {    
                    var str2 = JSON.parse(rowData);
                    var col_data2 = str2.ans_reserver_Value;
                    var imgName2 = "";
                    var tooltip2 = "{" + col_data2 +"}";
    
                    switch (col_data2) {
                        case 0:
                            imgName2 = "tool_no";
                            tooltip2 = "No";
                            break;
                        case 1:
                            imgName2 = "tool_yes";
                            tooltip2 = "Yes";
                            break;
          
                    }
                    var resultarray2 = [imgName2, tooltip2];
                    return resultarray2;
                }

    You can refer below article  -

    https://community.dynamics.com/crm/b/mscrmshop/archive/2016/12/13/adding-icons-and-tooltips-to-grid-column-in-dynamics-365

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You do have a type in your script (str). Also, Two options is different than optionset value i.e. two option will return true/false so you need to use if and add you logic. Something like this-

    =============

    function yesOrNoToolTip(rowData, userLCID) {

       var str = JSON.parse(rowData);

       var col_data2 = str.ans_reserver_Value;

       var imgName2 = "";

       var tooltip2 = "{" + col_data2 + "}";

       if (col_data2) {

           imgName2 = "tool_yes";

           tooltip2 = "Yes";

       }

       else {

           imgName2 = "tool_no";

           tooltip2 = "No";

       }

       var resultarray2 = [imgName2, tooltip2];

       return resultarray2;

    }

    =================

    Hope this helps.

  • Community Member Profile Picture
    on at

    Hi, Is there a way to add webresources to personal views?

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    HI,

    I don't think this is possible as of now.

    If found helpful, Please mark my answer verified.

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hi,

    Were you able to fix this issue?

    Please provide working code so that it will be helpful to other who might be facing the same issue.

    If found helpful, Please mark my answer verified.

  • Suggested answer
    Anas Rafik Profile Picture
    365 on at

    This is the working code :

    function yesOrNoToolTip(rowData, userLCID) {  
    
       var str = JSON.parse(rowData);
    
       var col_data = str.ans_reserver_Value;
    
       var imgName = "";
    
       var tooltip = "{"   col_data  "}";
    
       switch (col_data) {
    
          case false:
    
            imgName = "tool_no";
    
            tooltip = "No";
    
            break;
    
          case true:
    
             imgName = "tool_yes";
    
             tooltip = "Yes";
    
             break;
    
       }
    
       var resultarray = [imgName, tooltip];
    
       return resultarray;
    
    } // END

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans