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 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. }
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156