Use following JavaScript functions to disable lookup fields hyperlinks on Header, Body, Footer sections on any CRM form
Example method to disable Owner and Primary Contact fields on Header, PrimaryContact field on Body and CreatedBy,ModifiedBy fields on Footer on Account form
Call DisableLinks() in the account form load and include other methods in Account entity JavaScript file.
//disable Owner field on Header, Account field on Body and CreatedBy field on Footer function DisableLinks() { DisableHeaderLinks("ownerid"); DisableHeaderLinks("primarycontactid"); DisableLookupLinks("primarycontactid"); DisableFooterLinks("createdby"); DisableFooterLinks("modifiedby"); } //to disable Lookup hyderlinks function DisableLookupLinks(lookupFieldName) { var lookupParentNode = document.getElementById(lookupFieldName + "_d"); var lookupSpanNodes = lookupParentNode.getElementsByTagName("SPAN"); for (var spanIndex = 0; spanIndex < lookupSpanNodes.length; spanIndex++) { var currentSpan = lookupSpanNodes[spanIndex]; // Hide the hyperlink formatting currentSpan.style.textDecoration = "none"; currentSpan.style.color = "#000000"; // Revoke click functionality currentSpan.onclick = function () { }; } } //to disable Footer hyperlinks function DisableFooterLinks(lookupFieldName) { var lookupParentNode = document.getElementById("footer_" + lookupFieldName + "_d"); var lookupSpanNodes = lookupParentNode.getElementsByTagName("SPAN"); for (var spanIndex = 0; spanIndex < lookupSpanNodes.length; spanIndex++) { var currentSpan = lookupSpanNodes[spanIndex]; // Hide the hyperlink formatting currentSpan.style.textDecoration = "none"; currentSpan.style.color = "#000000"; // Revoke click functionality currentSpan.onclick = function () { }; } } //to disable Header hyperlinks function DisableHeaderLinks(lookupFieldName) { var lookupParentNode = document.getElementById("header_" + lookupFieldName + "_d"); var lookupSpanNodes = lookupParentNode.getElementsByTagName("SPAN"); for (var spanIndex = 0; spanIndex < lookupSpanNodes.length; spanIndex++) { var currentSpan = lookupSpanNodes[spanIndex]; // Hide the hyperlink formatting currentSpan.style.textDecoration = "none"; currentSpan.style.color = "#000000"; // Revoke click functionality currentSpan.onclick = function () { }; } }
sorry. is a method supported?
This is unsupported now. The example shown above was for CRM 2011. All the DOM related scripts are now deprecated. Please use XRM.*
Can you suggest any way to do now, as it is deprecated.