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,223 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:jgould763
ID: 24118198
new_basysshipzone
0
 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: You must have administrative privileges in order to configure lead or case queues. Salesforce.com (http://www.Salesforce.com) is a cloud-based customer relationship management (CRM) system. It is widely used around the world by sales and ma…
Note: You must have administrative privileges in order to create/edit Sharing Rules. Salesforce.com (http://www.salesforce.com) (SFDC) is a cloud-based customer relationship management (CRM) system. It is a database most commonly used by sales an…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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