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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • 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,983 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,983 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans