Hi all,
I have several custom entities that enable the user to assign to the form
one of the contacts of the account related firm. However, when the user want
to select
one of the contact persons (let's say there are five contact persons in that
company) he is directed to a lookup of *ALL* the contacts in the CRM.
Those custom entites are 1(Account) to many (some custom entity).
It seems that the custom entity doesn't know the contacts of the Account firm
which is related to. How do I confine the lookup to only subset of contacts
that
are relevant to the particular company?

Re: contact subset when lookup by Michael

Michael
Sat May 10 15:37:03 CDT 2008

Filtering lookups is not available in CRM 4.0. There was an undocumented
feature in CRM 3, allowing to specify a FetchXml query at runtime and filter
the results. However, in CRM 4.0 it doesn't work. If you are interested in a
custom solution, feel free to look at my website at www.stunnware.com.

--
Michael Höhne, Microsoft Dynamics CRM MVP

CRM Blog: http://www.stunnware.com/?area=blog

----------------------------------------------------------

"4crm4" <4crm4@discussions.microsoft.com> schrieb im Newsbeitrag
news:68E98B7D-8515-4499-9FED-64A571946572@microsoft.com...
> Hi all,
> I have several custom entities that enable the user to assign to the
> form
> one of the contacts of the account related firm. However, when the user
> want
> to select
> one of the contact persons (let's say there are five contact persons in
> that
> company) he is directed to a lookup of *ALL* the contacts in the CRM.
> Those custom entites are 1(Account) to many (some custom entity).
> It seems that the custom entity doesn't know the contacts of the Account
> firm
> which is related to. How do I confine the lookup to only subset of
> contacts
> that
> are relevant to the particular company?



RE: contact subset when lookup by Per

Per
Thu May 29 20:21:01 CDT 2008

I do it this way (thanks to some other posts somewhere) - and absolutely
unsupported:

Fix to CRMWeb\_controls\lookup\lookupsingle.aspx on server:

After:
<%@ Register ...
add:

<%-- pgn start 2008-05-01: to enable filtered lookup --%>
<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)
{
if( Request["search"] + "" != "" && Request["browse"] + "" == "1" )
{
crmGrid.AddParameter("fetchxml", Request["search"] );
crmGrid.Parameters.Remove("searchvalue");
}
}
</script>
<%--pgn end 2008-05-01 --%>

...<script language="javascript">


In form OnLoad event:

// Create lookup of only contacts associated with account
// Note: requires modification to CRMWeb\_controls\lookup\lookupsingle.aspx
setContactLookups = function()
{
if( crmForm.all.hdm_accountid.DataValue != null )
{
var entityForList = "contact";
var attribForFilter = "parentcustomerid" ;
var idToFetch = crmForm.all.hdm_accountid.DataValue[0].id+ "" ;
var fetchStr = "<fetch mapping='logical'>" +
" <entity name='" + entityForList + "'>" +
" <all-attributes />" +
" <filter>" +
" <condition attribute='" + attribForFilter
+ "' operator='eq' value='"+ idToFetch + "' />" +
" </filter>" +
" </entity>" +
"</fetch> ";

crmForm.all.hdm_contactid.lookupbrowse = 1;
crmForm.all.hdm_contactid.additionalparams = "search=" + fetchStr;
crmForm.all.hdm_contactid.setAttribute("readonly", false);
}
else
{
//accountid is null
crmForm.all.hdm_contactid.setAttribute("readonly", true);
}
}

setContactLookups();I do it this way:

--
Best regards,
Per


"4crm4" wrote:

> Hi all,
> I have several custom entities that enable the user to assign to the form
> one of the contacts of the account related firm. However, when the user want
> to select
> one of the contact persons (let's say there are five contact persons in that
> company) he is directed to a lookup of *ALL* the contacts in the CRM.
> Those custom entites are 1(Account) to many (some custom entity).
> It seems that the custom entity doesn't know the contacts of the Account firm
> which is related to. How do I confine the lookup to only subset of contacts
> that
> are relevant to the particular company?