Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

Multi Lookup OnChange Error

$
0
0
Hi Everybody,

I'm about to pull my hair out with this one, I have used this script multiple times without any issues but for some reason this doesn't want to work now. I'm sure it something simple that I am overlooking. Here is the situation.

I have a Lookup where the user can select either an Account or a Contact, When I click the search button I have the option to select either but when I select either an account or a contact I get the following error.

There was an error with the fields customized event
Field: new_ownercompanyid
Event:onchange
Error:Object doesn't support this property or method

Here is my setup on the entity

3 Fields
new_ownercompanyid - Lookup to the Account Entity
new_ownercontactid - Lookup to the Contact Entity
new_owner - NVARCHART used for display in views




OnChange Script on the new_ownercompanyid field




crmForm.all.new_ownercontactid.DataValue = crmForm.all.new_ownercompanyid.DataValue[0].name;<br/>




OnLoad on the Form




var accountLookup = crmForm.all.new_ownercompanyid;var contactLookup = crmForm.all.new_ownercontactid;

accountLookup.lookuptypes = "1,2"; accountLookup.lookuptypenames = "account:1,contact:2"; accountLookup.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif";if (contactLookup.DataValue != null) { accountLookup.DefaultValue = contactLookup.DataValue; accountLookup.DataValue = contactLookup.DataValue;if (typeof (accountLookup.DataValue[0].data) != "undefined") { accountLookup.DefaultValue[0].data = accountLookup.DataValue[0].data; } } crmForm.all.new_ownercontactid_c.style.display = "none"; crmForm.all.new_ownercontactid_d.style.display = "none"; crmForm.all.new_owner_c.style.display = "none"; crmForm.all.new_owner_d.style.display = "none";



OnSave on the Form



var accountLookup = crmForm.all.new_ownercompanyid;var contactLookup = crmForm.all.new_ownercontactid;if (accountLookup.DataValue == null) {
   contactLookup.DataValue = null;
}else {var customer = accountLookup.DataValue[0];if (customer.type == "1") {
      contactLookup.DataValue = null;
   }else {
      contactLookup.DataValue = accountLookup.DataValue;
      accountLookup.DataValue = null;
   }
}
Thanks for the help

Viewing all articles
Browse latest Browse all 10280

Trending Articles