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,218 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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