Thursday, October 7, 2010

Disable the Links in a Lookup Field MS CRM 4.0

Sometimes simply making a Lookup field “read only” isn’t enough. Sometimes, you may want to restrict the ability to even follow the links held inside the field. so this is here how to handel that from the user.

//this a general function which takes the name of the lookup

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];

currentSpan.onclick = function() {};
}
}

now To disable a field's Lookup links, pass the field's schema name into the function.
DisableLookupLinks("<lookupfield_name>");

Sudhanshu

No comments:

Post a Comment