Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to restrick a Lookup to only related records

2 views
Skip to first unread message

BladesAway

unread,
Nov 28, 2009, 4:53:01 PM11/28/09
to
We are in the experimenting stages of CRM and have come across a
customization we would like to implement. Many of or accounts have multiple
contacts. We can obviously set the primary contact and all is well. The
problem that we have is that when we wantt o change the primary contact and
click on the look up we see all of the contacts in the system and not just
those that have the account as their parent account. We are wondering if
there is a way to customize so that when we click on the lookup contact from
the account form it will display only those contacts that have the account as
their parent account.

Thanks

Scott

AdamV

unread,
Nov 28, 2009, 6:30:14 PM11/28/09
to
Yes, this can be done, there are two parts to making this work.
Firstly, customise your Contact entity > Lookup view > click on "Add
Find Columns" > tick Parent Customer
Save changes and don't forget to publish.
So, now when you do a lookup for primary contact (or any other lookup
for a contact) you can search by parent company name as well as the
person's own name. This is useful on it's own (eg to assign a Case to a
contact it might be easier to find them by searching for the company).

So the second step is to do this lookup automatically.
Customise the Account entity main form, edit the form properties and add
an onLoad event (don't forget to enable it as well by ticking the box)
with the following single line of code (this might be broken across
lines in the newsgroup depending on your word wrapping, just enter as
one line):
crmForm.all.primarycontactid.additionalparams = 'search=' +
crmForm.all.name.value;

This adds a parameter to the primarycontactid field to pass to the
search box when the lookup is invoked, the parameter being the field
"name" which is the Account Name of the Account you are looking at.
Save and close, publish Account entity.

Now try and use the primary contact lookup from an Account form and you
should only see contacts who you have already identified as working for
that company (ie this is their parent account).
Notice that you can see the account name in the search box at the top
right, this is just a normal search, you have done nothing really odd
here other than saved time and ensured accuracy of entry.

If you are certain the primary contact should be someone not associated
with the account you can still add them (maybe they just don't have
parent account set yet or set incorrectly, or the primary contact works
for a parent / child / sister company but is still the main decision
maker for this subsidiary). Simply clear the search box and look for a
name in the usual way. In other words, the customisation outlined above
changes the default behaviour but does not 'lock you in' or break the
normal built in behaviour.

I hope this helps
Adam Vero
MCT, MBMSS, MCSA

BladesAway

unread,
Dec 1, 2009, 9:15:01 PM12/1/09
to
Thank you. That worked perfectly!

"AdamV" wrote:

> .
>

AdamV

unread,
Dec 3, 2009, 11:03:05 AM12/3/09
to
You're welcome!

bayareacrm

unread,
Dec 9, 2009, 5:33:21 PM12/9/09
to
Hey Adam - thanks for the nugget - I just had a requirement that the customer
opt out of the filter, and this is a perfect solution!

Michael D. Mayo

"AdamV" wrote:

> .
>

AdamV

unread,
Dec 9, 2009, 6:30:26 PM12/9/09
to
That's what I like about public forums - an answer to help one person
can carry on being useful to others who come along too.

Steen Schl�ter Persson

unread,
Dec 15, 2009, 10:02:48 AM12/15/09
to
Hi Adam,

I have also tried your suggestion, and while it works in most cases, if
fails if the Customer Name contains an "&" sign.
There might be other character that makes it fail as well, but this one was
one I saw last week.Maybe there is a way to get around this?


--
Regards
Steen Schl�ter Persson (DK)


"AdamV" <nos...@meteorit.co.uk> wrote in message
news:%23C8oXeS...@TK2MSFTNGP04.phx.gbl...

jdubb

unread,
Jan 6, 2010, 12:24:38 PM1/6/10
to
On Dec 15 2009, 10:02 am, "Steen Schlüter Persson"

<st...@REMOVETHISasavaenget.dk> wrote:
> Hi Adam,
>
> I have also tried your suggestion, and while it works in most cases, if
> fails if the Customer Name contains an "&" sign.
> There might be other character that makes it fail as well, but this one was
> one I saw last week.Maybe there is a way to get around this?

This works to eliminate the &:
crmForm.all.primarycontactid.additionalparams = 'search=' +
encodeURIComponent(crmForm.all.name.DataValue);

AdamV

unread,
Jan 7, 2010, 6:43:34 AM1/7/10
to
Nice tip, thanks for the extra detail, I'll add that to my 'bag of tricks'
Adam

jdubb wrote:
> On Dec 15 2009, 10:02 am, "Steen Schl�ter Persson"

0 new messages