Answered by:
How to disable a field by picklist selection

Question
-
I am trying to modify an entity form so that another field will be enabled or disable depending on the selection of a drop down. I have this both the onload and onsave. event. This is causing CRM to crash. Below is the code:
if (crmForm.all.new_pipelinestatus.DataValue != 3 || crmForm.all.new_pipelinestatus.DataValue != 7)
{
// to disable a field
crmForm.all.new_lastfollowupdate.disabled = true;
}The above code is very simple but It does not work. The Picklist is called new_pipelinestatus and the field to be disabled is a date field called new_lastfollowupdate.
Can anybody tell me what is wrong with this? I cant see why it would not work or cause problems in CRM
Monday, May 23, 2011 8:48 PM
Answers
-
Hi,
Try changing 'disabled' to 'Disabled':
if (crmForm.all.new_pipelinestatus.DataValue != 3 || crmForm.all.new_pipelinestatus.DataValue != 7)
{
// to disable a field
crmForm.all.new_lastfollowupdate.Disabled = true;
}Hope that helps,
Rob
Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd.- Proposed as answer by Jamie MileyModerator Monday, May 23, 2011 9:41 PM
- Marked as answer by Deene Ogden Thursday, May 26, 2011 3:36 PM
Monday, May 23, 2011 9:10 PMAnswerer
All replies
-
You should try the debugging technique laid out here. It works for CRM 4.0 also.
http://mileyja.blogspot.com/2011/05/debugging-jscript-in-microsoft-dynamics.html
It might help you figure out what is breaking and why.
Jamie Miley
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Monday, May 23, 2011 9:08 PMModerator -
Hi,
Try changing 'disabled' to 'Disabled':
if (crmForm.all.new_pipelinestatus.DataValue != 3 || crmForm.all.new_pipelinestatus.DataValue != 7)
{
// to disable a field
crmForm.all.new_lastfollowupdate.Disabled = true;
}Hope that helps,
Rob
Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd.- Proposed as answer by Jamie MileyModerator Monday, May 23, 2011 9:41 PM
- Marked as answer by Deene Ogden Thursday, May 26, 2011 3:36 PM
Monday, May 23, 2011 9:10 PMAnswerer -
In addition to Rob's pointer, I think you may also have to re-evaluate your logic. The predicate:
crmForm.all.new_pipelinestatus.DataValue != 3 || crmForm.all.new_pipelinestatus.DataValue != 7
will always evaluate to 'true'.
--pogo (pat) @ pogo69.wordpress.com- Proposed as answer by Jamie MileyModerator Monday, May 23, 2011 9:41 PM
Monday, May 23, 2011 9:34 PM -
I did take predicate logic in school but I guess i brain dumped most of it.
I read the article mentioned above for stepping through the Javascript and was able to troubleshoot the code. I changed the logic and uppercased the "D" and now the code works. Thanks for your help and pointers guys!
Thanks,
Deene
Thursday, May 26, 2011 3:36 PM