I have created the attached function and I would like to run it for a collection of records, however some records are missing the inputs for the fields needed to run the function. Is it possible to code the function such that when there is no input in the field, the function skips that record and carries on to the next record? Ideally, it should also insert a comment to the form stating which record was lacking input in which field.
float calculateKVGunder25(Client_Details Client)
{
KVGComm = 0.0;
VVGComm = 0.0;
SpitalComm = 0.0;
VVGpakette = 0.0;
MJVComm = 0.0;
Total = 0.0;
if ((((Client.KVG == "BenefitPLUS/ Hausartz") || (Client.KVG == "BenefitPLUS/TelMed")) || (Client.KVG == "PreMed 24")) || (Client.KVG == "Standard"))
{
KVGComm = (KVGComm + 50.0);
}
else
{
KVGComm = (KVGComm + 0.0);
}
myAge = (((Client.PoliceStartDate - Client.Date_of_Birth) / (1000 * 3600 * 24 * 365))).toLong();
if ((myAge >= 0) || (myAge <= 25))
{
if (Client.VVG.contains("COMPLETA"))
{
VVGComm = (VVGComm + 100.0);
}
if (Client.VVG.contains("Vivante"))
{
VVGComm = (VVGComm + 160.0);
}
if (Client.VVG.contains("Dentaplus Combi"))
{
VVGComm = (VVGComm + 160.0);
}
if (Client.VVG.contains("Cura"))
{
VVGComm = (VVGComm + 100.0);
}
if (Client.VVG.contains("Dentaplus Gold"))
{
VVGComm = (VVGComm + 140.0);
}
if (Client.VVG.contains("Dentaplus Silber"))
{
VVGComm = (VVGComm + 100.0);
}
if (Client.VVG.contains("Dentaplus Bronze"))
{
VVGComm = (VVGComm + 60.0);
}
if (Client.VVG.contains("DentaPlus Light"))
{
VVGComm = (VVGComm + 60.0);
}
if (Client.VVG.contains("World"))
{
VVGComm = (VVGComm + 10.0);
}
if (Client.VVG.contains("Primeo"))
{
VVGComm = (VVGComm + 120.0);
}
if (Client.VVG.contains("Advocare PLUS") && (myAge > 19.0))
{
VVGComm = (VVGComm + 20.0);
}
if (Client.VVG.contains("SANA"))
{
VVGComm = (VVGComm + 20.0);
}
if (Client.VVG.contains("TOP"))
{
VVGComm = (VVGComm + 30.0);
}
if (Client.Spital_Versicherung.contains("Hospital Extra"))
{
SpitalComm = (SpitalComm + 10.0);
}
else if (Client.Spital_Versicherung.contains("Hospital ECO"))
{
SpitalComm = (SpitalComm + 20.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Classica"))
{
SpitalComm = (SpitalComm + 180.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Plus"))
{
SpitalComm = (SpitalComm + 160.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Comfort"))
{
SpitalComm = (SpitalComm + 180.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Flex 1"))
{
SpitalComm = (SpitalComm + 120.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Flex 2"))
{
SpitalComm = (SpitalComm + 140.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Plus BONUS"))
{
SpitalComm = (SpitalComm + 0.0);
}
else if (Client.Spital_Versicherung.contains("Hospital Comfort Bonus"))
{
SpitalComm = (SpitalComm + 0.0);
}
if (Client.VVG.contains("COMPLETA") && Client.Spital_Versicherung.contains("Hospital ECO"))
{
VVGpakette = (VVGpakette + 190.0);
}
else if (Client.VVG.contains("TOP") && Client.Spital_Versicherung.contains("Hospital ECO"))
{
VVGpakette = (VVGpakette + 170.0);
}
else if (Client.VVG.contains("TOP") && Client.Spital_Versicherung.contains("Hospital Flex 1"))
{
VVGpakette = (VVGpakette + 130.0);
}
else if (Client.VVG.contains("COMPLETA") && Client.Spital_Versicherung.contains("Hospital Flex 1"))
{
VVGpakette = (VVGpakette + 300.0);
}
else if (Client.VVG.contains("TOP") && Client.Spital_Versicherung.contains("Hospital Flex 2"))
{
VVGpakette = (VVGpakette + 150.0);
}
else if (Client.VVG.contains("COMPLETA") && Client.Spital_Versicherung.contains("Hospital Flex 2"))
{
VVGpakette = (VVGpakette + 330.0);
}
else if (Client.VVG.contains("COMPLETA") && Client.Spital_Versicherung.contains("Hospital Classica"))
{
VVGpakette = (VVGpakette + 305.0);
}
else if (Client.VVG.contains("TOP") && Client.Spital_Versicherung.contains("Hospital Classica"))
{
VVGpakette = (VVGpakette + 195.0);
}
else if (Client.VVG.contains("TOP") && (Client.Spital_Versicherung.contains("Hospital Plus") || Client.Spital_Versicherung.contains("Hospital Comfort")))
{
VVGpakette = (VVGpakette + 205.0);
}
else if (Client.VVG.contains("COMPLETA") && (Client.Spital_Versicherung.contains("Hospital Plus") || Client.Spital_Versicherung.contains("Hospital Comfort")))
{
VVGpakette = (VVGpakette + 315.0);
}
}
if (Client.Vetragsdauer = "1")
{
MJVComm = (MJVComm + 0.0);
}
else if (Client.Vetragsdauer = "3")
{
MJVComm = (MJVComm + 70.0);
}
else if (Client.Vetragsdauer = "5")
{
MJVComm = (MJVComm + 100.0);
}
Total = (Total + KVGComm + VVGComm + VVGpakette + MJVComm + SpitalComm);
insert into Check_2014
[
Added_User = zoho.loginuser
Age = myAge
Kunde = Client.ID
KVGComm = KVGComm
MJVComm = MJVComm
Provision = Client.MyLabel
SpitalComm = SpitalComm
Total = Total
VVGComm = VVGComm
VVGPakette = VVGpakette
]
return Total;
}