<CRM site folder>\_controls\lookup\lookupsingle.aspx dizinine yazılacak kod;
<script runat="server">
protected override void OnLoad( EventArgs e )
{
base.OnLoad(e);
crmGrid.PreRender += new EventHandler( crmgrid_PreRender );
}
void crmgrid_PreRender( object sender , EventArgs e )
{
// As we don't want to break any other lookups, ensure that we use workaround only if
// search parameter set to fetch xml.
if (crmGrid.Parameters["search"] != null && crmGrid.Parameters["search"].StartsWith("<fetch"))
{
crmGrid.Parameters.Add("fetchxml", crmGrid.Parameters["search"]);
// searchvalue needs to be removed as it's typically set to a wildcard '*'
crmGrid.Parameters.Remove("searchvalue");
// Icing on a cake - ensure that user cannot create new contact outside of the account
// and then select it.
this._showNewButton = false;
}
}
</script>
Filtreleme yapmak istediğimzi bir lookupı aşağıdaki şekilde bir fecht xml ile kolayca filtreleyebilriz.
onchange event a;
var field = crmForm.all.new_ilceid;
if( crmForm.all.new_ilid.DataValue == null || crmForm.all.new_ilid.DataValue=="")
{
debugger;
crmForm.all.new_ilceid.DataValue=null;
// Disable lookup for new account record as there can be no contacts
//field.Disabled = true;
}
else
{
field.lookupbrowse = 1;
crmForm.all.new_ilceid.DataValue=null;
debugger;
field.AddParam("search",
"<fetch mapping='logical'><entity name='new_ilce'>"
+ "<filter><condition attribute='new_ilid' operator='eq' value='"
+ crmForm.all.new_ilid.DataValue[0].id
+ "' /></filter></entity></fetch>");
//field.additionalparams += "&selObjects=1&findValue=0";
}
İşte sonuç ;
Kaynak:http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx
Hiç yorum yok:
Yorum Gönder