I am using the last solution described in this problem to read in a product price.
and my code is
C#[VisibleInDetailView(true)]
[VisibleInListView(true)]
[ImmediatePostData]
[NotMapped]
[DisplayName("Product")]
public virtual Product DisplayProduct
{
get
{
return Product;
}
set
{
Product = value;
if (Product != null)
{
var os = ObjectSpace;
if (SalesHeader.PriceList == null)
{
throw new ExceptionDataValidation("uh uh price list is not entered");
}
var priceList = os.FindObject<PriceList>(CriteriaOperator.Parse("[Id]=? ", SalesHeader.PriceList.Id));
if (priceList == null)
{
throw new ExceptionDataValidation("uh uh price list is not found");
}
Description = Product.Description;
TaxRate = os.FindObject<TaxRate>(CriteriaOperator.Parse("[Id]=? ", HandyDefaults.DefaultTaxRate(os).Id));
if (SalesHeader.PriceList.PriceListType == PriceListTypeEnum.DiscountFromRetailPrice)
{
Price = Product.RetailPrice * (100 - priceList.Percentage) / 100;
}
else
{
Price = Product.StandardCost * (100 + priceList.Percentage) / 100;
}
os.SetModified(this);
}
}
}
My problem is that the error displays as " An exception has been thrown by the target of an invocation"
How do I get the desired exception message to be displayed?
I don't think validation rules will work because they only get checked on Saving.