How to Create Custom LookUp on MSCRM 30

Creating lookup on CRM.We need 2 text fields on Appropriate CRM Entity and also have to publish on CRM Form invisibly.
(
LookupObjects(lookupField, lookupStyle, lookupClass, lookupTypes, lookupBrowse, bindingColumns, additionalParams, showNew, showProp, bPopulateLookup, defaultType, searchString) n

)

Javascript code must be run OnLoad Event;

function ChangeDisplayPicture(object,OnOff)
{
var obj = document.getElementById(object);
if ( obj != null )
{
if (OnOff == 'On')
obj.src = '/_imgs/btn_on_lookup.gif';
else
obj.src = '/_imgs/btn_off_lookup.gif';
}
}

function OpenSelectedDetails(namefield, idfield, typecodefield)
{
// Window resize functions at the beginning and end of the function for Turkish Character Bug in MSCRM
window.resizeBy(2,2);
nameObject = window.document.forms("crmForm").elements(namefield);
IdObject=window.document.forms("crmForm").elements(idfield);
TypeCode=window.document.forms("crmForm").elements(typecodefield);
if ( nameObject.value == "" IdObject.value == "" TypeCode.value == "" )
{
window.resizeBy(-2,-2);
return;
}
switch (TypeCode.value)
{
case '2' :
window.open('/sfa/conts/edit.aspx?id=' + IdObject.value ,'Contact','width=1200, height=800, toolbar=no, menubar=no, status=no, resize=no, resizable=no, directories=no, scrollbars=yes');
break;
case '1' :
window.open('/sfa/accts/edit.aspx?id=' + IdObject.value ,'Account','width=1200, height=800, toolbar=no, menubar=no, status=no, resize=no, resizable=no, directories=no, scrollbars=yes');
break;
case '4' :
window.open('/sfa/leads/edit.aspx?id=' + IdObject.value ,'Lead','width=1200, height=800, toolbar=no, menubar=no, status=no, resize=no, resizable=no, directories=no, scrollbars=yes');
break;
}
window.resizeBy(-2,-2);
}
function OpenCustomLookup( namefield, idfield, typecodefield)
{
.......
nameObject = window.document.forms("crmForm").elements(namefield);
IdObject=window.document.forms("crmForm").elements(idfield);
TypeCode=window.document.forms("crmForm").elements(typecodefield);
if(nameObject.Disabled)
{
window.resizeBy(-2,-2); return;
}
var o = LookupObjects(nameObject, "single", "ActivityRecipient", "1,2,4", "", null, null, null, null, null, null);
if (o && o.items.length > 0)
{
_oItem = new Object();
var li = o.items[0];
_oItem.Name = li.name;
_oItem.Id = li.id;
_oItem.Type = li.type nameObject.value = _oItem.Name;
IdObject.value = _oItem.Id;
TypeCode.value = _oItem.Type;
}
else
{
nameObject.value = "";
IdObject.value = "";
TypeCode.value = "";
}
window.resizeBy(-2,-2);
nameObject.FireOnChange();
}
// Custom Lookup Field Registrationfunction
RegisterCustomLookup(namefield, idfield, typecodefield)
{
document.getElementById(namefield).readOnly = true;
document.getElementById(idfield).readOnly = true;
document.getElementById(typecodefield).readOnly=true;
var n = document.getElementById(namefield);
n.style.align = 'left';
n.style.color = '#0000ff';
n.style.textDecoration = 'underline';
n.style.cursor = 'hand';
var sImage = '
';
var oElement = document.getElementById(namefield + '_d');
var sElement = '' + oElement.innerHTML + '';
oElement.innerHTML = sImage + sElement;
}

Comments

Popular posts from this blog

Assembly Microsoft.Dynamics.Service.Plugins.dll can not be loaded. Dynamics CRM 365 Engine version 9 - CRM User creation error

Exception caught instantiating TERADATA report server extension SQL Reporting Services

Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified at Configuration class initiation in CrmServiceHelper.cv