- Display account in customerid when contact is chosen in responsibl
- Posted by m1sterd on November 12th, 2007
Hi,
On the case form, I want to achieve the following behaviour :
1. Limit the customer to accounts (no contacts) -> ok
2. When the user chooses an account as customer, filter the responsible
contacts lookup field -> ok
3. When the user chooses a contact in the responsible contact field, display
automatically in the customer lookup field the account that contact is
related to. I don't know how to do that. Can you help?
Thanks!
- Posted by MD on November 12th, 2007
I'm assuming by you "OK" that you have the necessary JScript to accomplish
this? If so, the easiest thing would be using additional JScript to Disable
the Responsible Contact field until the Customer (Account) is selected.
Your OnLoad code would disable the responsiblecontactid field unless the
customerid field has a value. It would be something like:
if(crmForm.all.customerid == null)
{
crmForm.all.responsiblewcontactid.Disabled = true;
}
Put this same logic in the CustomerId's OnChange event, so that once the
form is loaded, if the user selects an Account, the responsiblecontactid
field is enabled.
Instructing the user on the Case form itself to select an Account before
selecting the Responsible Contact will help make this process clear. You can
accomplish this creating a "Section" without any data fields or line
separator, just the text telling the user what to do.
Hope this make sense...
"m1sterd" wrote:
- Posted by m1sterd on November 12th, 2007
Hi,
Thank you for your answer. It makes sense, but this is not what I want to
achieve. The user needs to be able to create a new case directly from the
contact form, in which 'case' I want the related account to be displayed
directly in the customerid field. So this would go in onload and of course in
onchange because i want permanent consistency on the screen.
"MD" wrote:
- Posted by MD on November 12th, 2007
I see. There are a number of usefull blogs to help you accomplish this:
http://www.stunnware.com/crm2/
Extremely helpfull... navigate to "Samples" --> JavaScript.
I found some code on one of the blogs that I put to use recently, but for
the life of me, I cannot find the actual blog post! It was very helpfull, so
here's the code I used:
if(crmForm.FormType == 2)
{
crmForm.all.primarycontactid.lookupbrowse = 1;
crmForm.all.primarycontactid.additionalparams = "fetchXml=<fetch
mapping='logical'> <entity name='contact'> <all-attributes/><filter
type='and'> <condition attribute='parentcustomerid' operator='eq' value='" +
crmForm.ObjectId + "'/></filter></entity></fetch>";
}
crmForm.all.primarycontactid.additionalparams += "&selObjects=2&findValue=0";
This filters the PrimaryContactId to include only the Contacts associated
with the Account. Since your requirements are similar, this may help get you
started. And if anyone knows where this code originated, please let us know...
"m1sterd" wrote:
- Posted by Michael Höhne on November 12th, 2007
The original code was posted by "Nergock" ->
http://groups.google.de/group/micros...43db2536caac00
--
Michael Höhne, Microsoft Dynamics CRM MVP
Web: http://www.stunnware.com/crm2
Feed: http://www.stunnware.com/crm2/atom.aspx
Custom Lookup Dialog: http://www.stunnware.com/crm2/?area=customLookup
The JavaScript Snippets Directory:
http://www.stunnware.com/crm2/topic.aspx?id=JS13
----------------------------------------------------------
"MD" <MD@discussions.microsoft.com> schrieb im Newsbeitrag
news:E5EE3085-8CC2-421F-A65B-8D3411E32745@microsoft.com...
- Posted by m1sterd on November 13th, 2007
Thank you for that piece of code which I am getting to know pretty well.
Indeed, as I said in my first post, I managed to filter the lookups, using
this exact code.
But I can't find anywhere is simply how to get something directly displayed
in the lookup according to another lookup's value.
thanks
"MD" wrote:
- Posted by Bertil on November 13th, 2007
You might want to take a look at this:
http://blogs.delta-n.nl/crm/Lists/Posts/Post.aspx?ID=3
It uses the same construction as you would need to get the information
required to fill the account.
Good luck,
Bertil
"m1sterd" wrote: