Hello,
i programmed an update-plugin with PreImage on entity "quotedetails" which calculates a sum of
a.) sales rebate ("rabattvertrieb")and
b.) yearly payment rebate ("rabattjahresbuchung1").
My Problem is that user can empty the field sales rebate , so that the money field has no value anymore. If user does so and saves the quotedetail, the plugin throws an error "object not defined".
How can i avoid that error, if an empty money field appears?
Code snippets regarding that look like:
Money rabattvertrieb = new Money();
rabattvertrieb.Value = (decimal)0;
if (entity.Attributes.Contains("fitsfp_rabattvertrieb"))
{
rabattvertrieb = (Money)entity.Attributes["fitsfp_rabattvertrieb"];
}
else
{
//Prüfen ob das Attribut im Image enthalten ist
if (image.Attributes.Contains("fitsfp_rabattvertrieb"))
{
rabattvertrieb = (Money)image.Attributes["fitsfp_rabattvertrieb"];
}
}
....
Money summerabatt = new Money(rabattvertrieb.Value + rabattjahresbuchung1.Value);
...
if (entity.Attributes.Contains("fitsfp_rabattvertrieb"))
{
entity.Attributes["fitsfp_rabattvertrieb"] = ((Money)rabattvertrieb);
}
else
{
entity.Attributes.Add("fitsfp_rabattvertrieb", (Money)rabattvertrieb);
}
I don't get the clue how to catch that empty values, maybe someone can give me advice.
Thanks in advance,
Ulrich
Microsoft Certified Professional | Microsoft Certified Partner