Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
1,243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

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 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 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