Hi
We have created two custom entities named suppliers and business partners.
We would prefer not to create account records and use the relationship type
field so we created these custom entities.
We now have on the Contact form three seperate fields that a contact could
be related to. These fields are parent customer, parent supplier and parent
business partner. A Contact should only be associated with one parent record.
We would like to write Jscript which hides the remaining fields if one of
the fields is populated. If a user associates a Contact with a parent
customer then the parent business partner and parent supplier fields are
hidden.
If I use the On Save event, the question is, how do I hide the remaining
fields if a certain value is selected in one of the fields? I only want to
hide the fields that are not populated.
I suppose I could use a script which if all fields are null then do nothing
however if one of the fields are populated then hide the fields that are
null. How would you translate this into Jscript?
I created a custom field named 'Contact Type' and tested the following script:
var type = crmForm.all.new_contacttype.SelectedText;
switch (type)
{
case "Business Partner
crmForm.all.parentcustomerid.style.visibility = 'hidden';
crmForm.all.parentcustomerid.style.position = 'absolute';
crmForm.all.parentcustomerid_c.style.visibility = 'hidden';
crmForm.all.parentcustomerid_c.style.position = 'absolute';
crmForm.all.parentcustomerid_d.style.visibility = 'hidden';
crmForm.all.parentcustomerid_d.style.position = 'absolute';
crmForm.all.new_parentbusinesspartnerid.style.visi bility = 'visible';
crmForm.all.new_parentbusinesspartnerid.style.posi tion = 'relative';
crmForm.all.new_parentbusinesspartnerid_c.style.vi sibility = 'visible';
crmForm.all.new_parentbusinesspartnerid_c.style.po sition = 'relative';
crmForm.all.new_parentbusinesspartnerid_d.style.vi sibility = 'visible';
crmForm.all.new_parentbusinesspartnerid_d.style.po sition = 'relative';
crmForm.all.new_parentsupplierid.style.visibility = 'hidden';
crmForm.all.new_parentsupplierid.style.position = 'absolute';
crmForm.all.new_parentsupplierid_c.style.visibilit y = 'hidden';
crmForm.all.new_parentsupplierid_c.style.position = 'absolute';
crmForm.all.new_parentsupplierid_d.style.visibilit y = 'hidden';
crmForm.all.new_parentsupplierid_d.style.position = 'absolute';
case "Supplier"
crmForm.all.parentcustomerid.style.visibility = 'hidden';
crmForm.all.parentcustomerid.style.position = 'absolute';
crmForm.all.parentcustomerid_c.style.visibility = 'hidden';
crmForm.all.parentcustomerid_c.style.position = 'absolute';
crmForm.all.parentcustomerid_d.style.visibility = 'hidden';
crmForm.all.parentcustomerid_d.style.position = 'absolute';
crmForm.all.new_parentbusinesspartnerid.style.visi bility = 'hidden';
crmForm.all.new_parentbusinesspartnerid.style.posi tion = 'absolute';
crmForm.all.new_parentbusinesspartnerid_c.style.vi sibility = 'hidden';
crmForm.all.new_parentbusinesspartnerid_c.style.po sition = 'absolute';
crmForm.all.new_parentbusinesspartnerid_d.style.vi sibility = 'hidden';
crmForm.all.new_parentbusinesspartnerid_d.style.po sition = 'absolute';
crmForm.all.new_parentsupplierid.style.visibility = 'visible';
crmForm.all.new_parentsupplierid.style.position = 'relative';
crmForm.all.new_parentsupplierid_c.style.visibilit y = 'visible';
crmForm.all.new_parentsupplierid_c.style.position = 'relative';
crmForm.all.new_parentsupplierid_d.style.visibilit y = 'visible;
crmForm.all.new_parentsupplierid_d.style.position = 'relative';
break;
case "Customer"
crmForm.all.parentcustomerid.style.visibility = 'visible';
crmForm.all.parentcustomerid.style.position = 'relative';
crmForm.all.parentcustomerid_c.style.visibility = 'visible';
crmForm.all.parentcustomerid_c.style.position = 'relative';
crmForm.all.parentcustomerid_d.style.visibility = 'visible';
crmForm.all.parentcustomerid_d.style.position = 'relative';
crmForm.all.new_parentbusinesspartnerid.style.visi bility = 'hidden';
crmForm.all.new_parentbusinesspartnerid.style.posi tion = 'absolute';
crmForm.all.new_parentbusinesspartnerid_c.style.vi sibility = 'hidden';
crmForm.all.new_parentbusinesspartnerid_c.style.po sition = 'absolute';
crmForm.all.new_parentbusinesspartnerid_d.style.vi sibility = 'hidden';
crmForm.all.new_parentbusinesspartnerid_d.style.po sition = 'absolute';
crmForm.all.new_parentsupplierid.style.visibility = 'hidden';
crmForm.all.new_parentsupplierid.style.position = 'absolute';
crmForm.all.new_parentsupplierid_c.style.visibilit y = 'hidden';
crmForm.all.new_parentsupplierid_c.style.position = 'absolute';
crmForm.all.new_parentsupplierid_d.style.visibilit y = 'hidden';
crmForm.all.new_parentsupplierid_d.style.position = 'absolute';
break;
This script was unsuccessful and I would ideally prefer not to create the
custom field named 'Contact Type'.
Thanks very much