Solved

How can I hide a field on a form in CRM 4.0 if a bit field is YES?

Posted on 2009-04-10
9
1,214 Views
Last Modified: 2013-11-24
I need to know how to hid a "Section" of the "Account" Entity Form is a bit field is set to "Yes"

This would need to be an "onChange" script for the bit field that will be used to toggle whether it the section is visible or not.
0
Comment
Question by:jgould763
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:crm_info
ID: 24118100
To hide a section, you can use this code:
crmForm.all.<insert schema name here>. parentElement.parentElement.parentElement.style.display = 'none';
To unhide a section, you can use this code:
crmForm.all.<insert schema name here>. parentElement.parentElement.parentElement.style.display = 'block';
Where <insert schema name here> is the name of any field in the section that you want to hide.
So, assuming you have a bit field named "new_hidesection" and, within the section, you have a field named "new_nameofdog", then the code below should work for you.
 
Signature deleted
modus_operandi, EE Moderator

// Insert this into the OnChange for the new_hidesection field

 

if (crmForm.all.new_hidesection.DataValue) then

{

  crmForm.all.new_nameofdog. parentElement.parentElement.parentElement.style.display = 'none';

}

else

{

  crmForm.all.new_nameofdog. parentElement.parentElement.parentElement.style.display = 'block'; 

}

Open in new window

0
 

Author Comment

by:jgould763
ID: 24118154
I'm not sure what pieces of this code I need to change for my exact needs.
Can you help?
 
The "bit" field that is to be used to toggle the view/hide is called "new_usedefaults"
 
The section to hide if the box is check is the "Basys" Section on a tab called "New Account Setup"
 
Are you able to tweek the code for me?  I'm a java beginner at best.
0
 
LVL 10

Expert Comment

by:crm_info
ID: 24118188
Sure...can you give me the name of one field within the section that you want to hide?  Any field name will do.  I need the system name, not the display name (probably something like "new_fieldname").
0
 

Author Comment

by:jgould763
ID: 24118198
new_basysshipzone
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 10

Expert Comment

by:crm_info
ID: 24118272
The code below should work for you.
// Insert this into the OnChange for the new_usedefaults field

 

if (crmForm.all.new_usedefaults.DataValue)

{

crmForm.all.new_basysshipzone.parentElement.parentElement.parentElement.style.display = 'none';

}

else

{

crmForm.all.new_basysshipzone.parentElement.parentElement.parentElement.style.display = 'block'; 

}

Open in new window

0
 

Author Comment

by:jgould763
ID: 24118325
That didn't work.  Do we need to say that  
if (crmForm.all.new_usedefaults.DataValue)  
equals something, then hide else show?
 
Also, the defaul value for the field is Yes but now that this code is in place, it defaults to no.
I think we are on the right track here.


0
 

Author Comment

by:jgould763
ID: 24118334
Actually it does work, I just needed to click out of the field, however, I do still have the issue with the fied defualting to "no"
0
 
LVL 10

Accepted Solution

by:
crm_info earned 500 total points
ID: 24118358
The code should work (I set it up in our environment and it works as expected) - but a couple of items to note:
* If your bit field is a checkbox, then it won't hide / unhide the field until after you've tabbed off of it.  If you want it to change as soon as the user changes the value in the checkbox, it will take more code than I have time to work on at the moment ... but you could change it to a picklist instead.
* I'm not sure why the default would be changing.  Are you testing it on a record that may already have its value set?
* Make sure that, if you copied/pasted the code, that you did not introduce any new line breaks that may cause it to fail.
* Make sure that the capitalization  on the field names is exactly right - JavaScript is case sensitive.
0
 

Author Comment

by:jgould763
ID: 24118676
You nailed it!!
 
I was opening an existing account where the field was set to "No'
 
Thanks a ton!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Hello All, In previous article we used Hortonworks sandbox to work with Hadoop. Now, lets think to create own single node Hadoop on Linux. Here we Install and Configure Apache Hadoop on UI based Oracle Linux. I assume, you have VMware installe…
Read about achieving the basic levels of HRIS security in the workplace.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now