Answered by:
CRM 4.0 Javascript - Selected Text

Question
-
Hi All;
Can anyone please help me to solve the belwo problem
I have 3 fields has below
1. Date of birth
2. Age ( text box)
3.Age range which is a drop downwhen i type the birthdate as 01/10/1980
the age gets displayed as 31
the Age range gets displayed as between 30 - 50 yrswhich is right but whn i run the report ( advanced find) on the Age range the reports displayed with previous or default value
I think the selected text in my below code is causing teh issue
Any help on this much appreciated
ThanksAgeGroup = function()
{if(crmForm.all.new_age.DataValue!= null)
{
if (crmForm.all.new_age.DataValue < 30 )
{
crmForm.all.new_agegroup.SelectedText = "Under 30";
crmForm.all.new_eligibleforerdf.DataValue = true;
}
else if (crmForm.all.new_age.DataValue > 29 && crmForm.all.new_age.DataValue <51 )
{
crmForm.all.new_agegroup.SelectedText ="30 to 50 Years";
crmForm.all.new_eligibleforerdf.DataValue = false;}
else if (crmForm.all.new_age.DataValue >50 && crmForm.all.new_age.DataValue < 66 )
{
crmForm.all.new_agegroup.SelectedText = "50 to 65 years";
crmForm.all.new_eligibleforerdf.DataValue = true;}
else if (crmForm.all.new_age.DataValue >65 )
{
crmForm.all.new_agegroup.SelectedText ="Over 65";
crmForm.all.new_eligibleforerdf.DataValue = true;}
}
else if (crmForm.all.new_age.DataValue = null)
{
crmForm.all.new_agegroup.SelectedText ="Not Stated";
crmForm.all.new_eligibleforerdf.DataValue = false;}
}
var loneparent = crmForm.all.new_loneparent.DataValue;
var gender = crmForm.all.new_gender.SelectedText;var disability1 = crmForm.all.new_disabilityid.DataValue == null ? "" : crmForm.all.new_disabilityid.DataValue[0].name;
var ethnicity = crmForm.all.new_ethnicitylookupid.DataValue == null ? "" : crmForm.all.new_ethnicitylookupid.DataValue[0].name;
var exoffender = crmForm.all.new_exoffender.DataValue;
var refugeeasylumseeker = crmForm.all.new_refugeeasylumseeker.DataValue;
var socialenterprise = crmForm.all.new_socialenterprise.DataValue;
var agegroup = crmForm.all.new_agegroup.SelectedText;
var wardelligibilityid = crmForm.all.new_wardelligibilityid.DataValue == null ? "" : crmForm.all.new_wardelligibilityid.DataValue[0].name;
if ( loneparent == true || gender == "Female" || exoffender == true || refugeeasylumseeker == true || agegroup == "Under 30" || agegroup == "50 to 65 years" || agegroup == "Over 65" || socialenterprise == true || wardelligibilityid =="eligible")
{
crmForm.all.new_eligibleforerdf.DataValue = true;
}
else if ( disability1 == "No Disability" || disability1 == "Not Stated" || disability1 == "Prefer Not to Say" || agegroup == "30 to 50 Years" || agegroup == "Not Stated" || ethnicity == "White British" || ethnicity == "Not Stated " || ethnicity == "Prefer Not to Say" || wardelligibilityid =="not eligible")
{
crmForm.all.new_eligibleforerdf.DataValue = false;
}
Pradnya07
- Edited by Simran08 Monday, July 2, 2012 2:35 PM
Monday, July 2, 2012 2:34 PM
Answers
-
HI Simran08,
I believe your problem might be caused if you have the age field locked or in read-only mode and that causes the value to not be saved when you click on Save in the form. You can force the field submission by adding the following lines at the end of your code.
crmForm.all.new_eligibleforerdf.ForceSubmit = true; crmForm.all.new_agegroup.ForceSubmit = true;
Regards,
Damian Sinay- Marked as answer by Simran08 Tuesday, July 3, 2012 8:17 AM
Tuesday, July 3, 2012 4:19 AM
All replies
-
HI Simran08,
I believe your problem might be caused if you have the age field locked or in read-only mode and that causes the value to not be saved when you click on Save in the form. You can force the field submission by adding the following lines at the end of your code.
crmForm.all.new_eligibleforerdf.ForceSubmit = true; crmForm.all.new_agegroup.ForceSubmit = true;
Regards,
Damian Sinay- Marked as answer by Simran08 Tuesday, July 3, 2012 8:17 AM
Tuesday, July 3, 2012 4:19 AM -
Thanks Damian it worked like a charm
just added one more line to it 'crmForm.all.new_agegroup.DataValue = 1
Pradnya07
Tuesday, July 3, 2012 8:17 AM