Previous Thread

7/25/2006 2:35:02 PM    Check Box Creates Null value
I have a number of check boxes on a form for which the attributes' default 
 
value is no (a value of 0). When the record is created, all check boxes are 
 
empty. If the user checks it, the answer is yes (a value of 1). 
 
HOWEVER the database value is NULL if I never check the box. The only way I 
 
can get a value of 0 is if I check and un-check the box. This problem does 
 
not surface if my form is formatted using two radio buttons. 
 
This makes the advanced find ineffective. 
 
Does anybody have any suggestions that would allow me to keep the more eye 
 
friendly check boxes over the radio buttons?



7/26/2006 12:18:35 AM    Re: Check Box Creates Null value
Sarah, 
 
I assume that the following happens: the initial value of your checkbox is 
 
0, so its unchecked. The IsDirty property of the html control handling the 
 
checkbox is set to false when loading the form. Checking and un-checking a 
 
checkbox will set IsDirty to true. As the CRM form only passes the dirty 
 
fields to the server, a checkbox that hasn't been touched will not be 
 
included in the post request, so the corresponding value in the database 
 
remains unchanged. 
 
What you can do is the following: in the OnLoad event set the ForceSubmit 
 
property of all checkboxes in question to true, if it is a create form (use 
 
crmForm.FormType to distinguish). I haven't tried it, but in theory it 
 
should populate the database with 0's and 1's. If it doesn't, you may also 
 
need to set the DataValue to false to initialize the fields correctly. 
 
-- 
 
Michael 
 
http://www.stunnware.com/crm 
 
---------------------------------------------------------- 
 
"Sarah Montgomery" <SarahMontgomery@discussions.microsoft.com> schrieb im 
 
Newsbeitrag news:DEDC6A76-68B3-498E-A8C5-137ABBA86F03@microsoft.com...

7/26/2006 8:10:38 AM    Re: Check Box Creates Null value
Sarah, 
 
In the onload of the page put the javascript: 
 
if (crmFom.all.picklist.datavalue == null) 
 
{ 
 
crmForm.all.picklist.DataValue = false; 
 
} 
 
Please double check the script first! 
 
Good luck, 
 
Regards 
 
Ron Wallegie 
 
"Sarah Montgomery" <SarahMontgomery@discussions.microsoft.com> wrote in 
 
message news:DEDC6A76-68B3-498E-A8C5-137ABBA86F03@microsoft.com...