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)

How to create Tool tip for an Option Set

(0) ShareShare
ReportReport
Posted on by 340

Hello,

I am working on Dynamics 365  Online version . I have an option set with 3 options , I  created a Tool Tip adding the description in each of the 3 options set values but unable to see any display text when i move the mouse over the the Option set on Form . Please note it is not a global option set .

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    KylieKiser Profile Picture
    2,174 on at

    Unfortunately the Tool Tips are only available at the field level not for each option out of the box.

    See more information here: https://technet.microsoft.com/en-us/library/dn531201.aspx 

    Unlike the Description for fields, the Description value for a global option set is not displayed as a tooltip when the field is used in a form. This description is only visible in the list of global options. You can use the description to provide information about why you have created this global option set and what it should be used for.

  • Suggested answer
    Fedorov Profile Picture
    40 on at

    I did it this way. It works in our environments (365 online). Code not optimized but you get the idea. It can surely be tweaked to suit your needs. 

    I my case I use jquery to find the DOM elements, you can probably re-write it to pure javascript if you don't want to use jquery.

    This method gets the optionset metadata

    GetOptionSetMetadata = function(entityLogicalName, optionSetLogicalName, callback)
        {
            var self = this;
            let url = self.config.APIUrl;       
    
            url  = "EntityDefinitions(LogicalName='"   entityLogicalName   "')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$filter=LogicalName eq '"   optionSetLogicalName   "'&$expand=OptionSet";
    
            var req = new XMLHttpRequest();
            req.open("GET", url, true);
            req.setRequestHeader("OData-MaxVersion", "4.0");
            req.setRequestHeader("OData-Version", "4.0");
            req.setRequestHeader("Accept", "application/json");
            req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
            req.onreadystatechange = function () {
                if (this.readyState === 4) {
                    req.onreadystatechange = null;
                    if (this.status === 200) {
                        var results = JSON.parse(this.response);
    
                        callback(results);
    
                        //for (var i = 0; i < results.value[0].OptionSet.Options.length; i  ) {
                        //    var Label = results.value[0].OptionSet.Options[i].Label.UserLocalizedLabel.Label;
                        //    alert(Label);
                        //}
                    } else {
                        Xrm.Utility.alertDialog(this.statusText);
                    }
                }
            };
            req.send();
    
        };
        CRMWebAPI.prototype.Get = funct

    This method sets the tooltip for each option, it is visible when hovering each option when the optionset is expanded

    setOptionsetTooltips = function (attributeLogicalName) {
        let api = releye.getCrmWebApi();
    
        var callback = function (result) {        
            let optionsMetadata = result.value[0].OptionSet.Options;
            let options = formContext.getAttribute(attributeLogicalName).getOptions();
            let indSegmentSelect = window.parent.$("select[id*='"  attributeLogicalName   "'")[0]; // Expect to find only one;   
            
            for (var i = 0; i < options.length; i  ) {            
                let optionId = options[i].value;
                let meta = optionsMetadata.find(opt => opt.Value == optionId);
    
                if (meta && meta.Description && meta.Description.UserLocalizedLabel) {
                    let tooltip = meta.Description.UserLocalizedLabel.Label;
                             
                    if(indSegmentSelect)
                    {
                        indSegmentSelect = $(indSegmentSelect);                    
                        let htmlOption = $(indSegmentSelect).find("option[value='"   optionId   "']");
                        if(htmlOption && htmlOption.length == 1)
                        {
                            console.log("Applied description "   tooltip   " to option "   optionId);
                            $(htmlOption).attr("title", tooltip);
                        }
                    }                
                }
            }
        }
    
        setTimeout(function () {
            api.GetOptionSetMetadata("account", attributeLogicalName, callback);
        }, 2000); // Wait for parent frame to load completely, otherwise it may not find the controls to set.
    }

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