E10: Data Directive - BLException repeats

Joe,

this is how I worked around this:

I added the following code to the begining of the C# code:



int z = 1;

foreach (var ttPart_iterator in (from ttPart_Row in ttPart
                                 where ttPart_Row.Company == Session.CompanyID &&
                                 z == 1
                                 select ttPart_Row))
{
z = z + 1;

/*Then the rest of the code*/


or


int z = 1;

foreach (var ttPart_xRow in ttPart)
{
if (z == 1)

{

    z = z + 1;
/*then the rest of the code*/


1 Like
Hi All,

I have a data directive on OrderDtl that checks to make sure that any line added or updated does not result in a zero price.
If it is a zero price line, it throws a BLException telling the user that it’s not allowed.

When adding a new line, BLException message shows three times in the same error box.
For example:
“Zero Price
Zero Price
Zero Price”

If I make the price greater than zero, save the new line, and then update the line so the price is zero, this message only displays once.

The data directive does a little more than I described but I was trying to keep it simply.
Any ideas on why a new line would show the message 3 times and an updates line only once?

Here is my complete code for this data directive:

Erp.Tables.OrderHed OrderHed;

if (callContextClient.AssemblyName == "Erp.UI.QuoteEntry")
{
return;
}
foreach (var ttOrderDtl_iterator in (from ttOrderDtl_Row in ttOrderDtl
where ttOrderDtl_Row.Company == Session.CompanyID
&& (string.Equals(ttOrderDtl_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
|| string.Equals(ttOrderDtl_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase))
&& ttOrderDtl_Row.KitFlag != "C"
select ttOrderDtl_Row))
{
var ttOrderDtlRow = ttOrderDtl_iterator;
/*validate kit when its ready to be validated*/
if (ttOrderDtlRow.KitFlag == "P" && ttOrderDtlRow.KitsLoaded == false)
{
return;
}
/* skip configured parts */
if (ttOrderDtlRow.RevisionNum != "" && ttOrderDtlRow.KitFlag == "")
{
return;
}

/*skip sample orders*/
if ((from x in Db.OrderHed where x.OrderNum == ttOrderDtlRow.OrderNum && x.CheckBox04 == true select x).Count() != 0)
{
return;
}
if ((ttOrderDtlRow.DocExtPriceDtl - ttOrderDtlRow.Discount) <= 0)
{
OrderHed = (from OrderHed_Row in Db.OrderHed
where OrderHed_Row.Company == Session.CompanyID
&& OrderHed_Row.OrderNum == ttOrderDtlRow.OrderNum
select OrderHed_Row).FirstOrDefault();
if (OrderHed != null)
{
if (!String.IsNullOrEmpty(OrderHed.Character08))
{
ttOrderDtlRow["Character09"] = OrderHed.Character08;
}
}
if (String.IsNullOrEmpty((string)ttOrderDtlRow["Character09"]))
{
CallContext.Current.ExceptionManager.AddBLException("No Charge Reason is Required.");
}
}
else
{
ttOrderDtlRow["Character09"] = "";
}
}





[cid:3dad21.png@053e9b0e.459d7272]


Joe Rojas
Director of Information Technology
(781) 408-9278 Mobile
(781) 573-0291 Local
(781) 232-5191 Fax


[http://matsinc.com/images/e-mail-signatures/tagline.jpg%5d
[http://matsinc.com/images/e-mail-signatures/graphics/logo_matsinc.png%5d<http://matsinc.com> [http://matsinc.com/images/e-mail-signatures/graphics/icon_twitter.png%5d <http://twitter.com/Mats_Inc> [http://matsinc.com/images/e-mail-signatures/graphics/icon_facebook.png%5d <http://www.facebook.com/commercial.flooring> [http://matsinc.com/images/e-mail-signatures/graphics/icon_youtube.png%5d <http://www.youtube.com/user/MatsIncTV> [http://matsinc.com/images/e-mail-signatures/graphics/icon_pinterest.png%5d <http://www.pinterest.com/contractfloors/> [http://matsinc.com/images/e-mail-signatures/graphics/icon_blog.png%5d <http://matsinc.com/blog>



[Non-text portions of this message have been removed]
Hi Joe,
DataDirectives get triggered several times when adding a new records, that could explain why you get the message multiple times. For this type of price validation I would recommend a PreProcessing directive on the Update method for that business object.  
 
Dora Chavarria   Sr. Consultant Analysis Services, ERP   Mayan Technologies USA, Inc. dchavarria@... www.mayantechs.com 



On Thursday, September 17, 2015 2:33 PM, "Joe Rojas jrojas@... [vantage]" <vantage@yahoogroups.com> wrote:


 
<div id="ygrps-yiv-890692247yiv1597771593ygrp-text">
  
  
  <div>Hi All,


I have a data directive on OrderDtl that checks to make sure that any line added or updated does not result in a zero price.
If it is a zero price line, it throws a BLException telling the user that it’s not allowed.

When adding a new line, BLException message shows three times in the same error box.
For example:
“Zero Price
Zero Price
Zero Price”

If I make the price greater than zero, save the new line, and then update the line so the price is zero, this message only displays once.

The data directive does a little more than I described but I was trying to keep it simply.
Any ideas on why a new line would show the message 3 times and an updates line only once?

Here is my complete code for this data directive:

Erp.Tables.OrderHed OrderHed;

if (callContextClient.AssemblyName == "Erp.UI.QuoteEntry")
{
return;
}
foreach (var ttOrderDtl_iterator in (from ttOrderDtl_Row in ttOrderDtl
where ttOrderDtl_Row.Company == Session.CompanyID
&& (string.Equals(ttOrderDtl_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
|| string.Equals(ttOrderDtl_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase))
&& ttOrderDtl_Row.KitFlag != "C"
select ttOrderDtl_Row))
{
var ttOrderDtlRow = ttOrderDtl_iterator;
/*validate kit when its ready to be validated*/
if (ttOrderDtlRow.KitFlag == "P" && ttOrderDtlRow.KitsLoaded == false)
{
return;
}
/* skip configured parts */
if (ttOrderDtlRow.RevisionNum != "" && ttOrderDtlRow.KitFlag == "")
{
return;
}

/*skip sample orders*/
if ((from x in Db.OrderHed where x.OrderNum == ttOrderDtlRow.OrderNum && x.CheckBox04 == true select x).Count() != 0)
{
return;
}
if ((ttOrderDtlRow.DocExtPriceDtl - ttOrderDtlRow.Discount) <= 0)
{
OrderHed = (from OrderHed_Row in Db.OrderHed
where OrderHed_Row.Company == Session.CompanyID
&& OrderHed_Row.OrderNum == ttOrderDtlRow.OrderNum
select OrderHed_Row).FirstOrDefault();
if (OrderHed != null)
{
if (!String.IsNullOrEmpty(OrderHed.Character08))
{
ttOrderDtlRow["Character09"] = OrderHed.Character08;
}
}
if (String.IsNullOrEmpty((string)ttOrderDtlRow["Character09"]))
{
CallContext.Current.ExceptionManager.AddBLException("No Charge Reason is Required.");
}
}
else
{
ttOrderDtlRow["Character09"] = "";
}
}





[cid:3dad21.png@053e9b0e.459d7272]


Joe Rojas
Director of Information Technology
(781) 408-9278 Mobile
(781) 573-0291 Local
(781) 232-5191 Fax


[http://matsinc.com/images/e-mail-signatures/tagline.jpg]
[http://matsinc.com/images/e-mail-signatures/graphics/logo_matsinc.png]<http://matsinc.com> [http://matsinc.com/images/e-mail-signatures/graphics/icon_twitter.png] <http://twitter.com/Mats_Inc> [http://matsinc.com/images/e-mail-signatures/graphics/icon_facebook.png] <http://www.facebook.com/commercial.flooring> [http://matsinc.com/images/e-mail-signatures/graphics/icon_youtube.png] <http://www.youtube.com/user/MatsIncTV> [http://matsinc.com/images/e-mail-signatures/graphics/icon_pinterest.png] <http://www.pinterest.com/contractfloors/> [http://matsinc.com/images/e-mail-signatures/graphics/icon_blog.png] <http://matsinc.com/blog>


[Non-text portions of this message have been removed]

</div>
 


<div style="color:#fff;height:0;"></div></div>
#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593 -- #ygrps-yiv-890692247yiv1597771593ygrp-mkp { border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mkp hr {
border:1px solid #d8d8d8;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mkp #ygrps-yiv-890692247yiv1597771593hd {
color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mkp #ygrps-yiv-890692247yiv1597771593ads {
margin-bottom:10px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mkp .ygrps-yiv-890692247yiv1597771593ad {
padding:0 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mkp .ygrps-yiv-890692247yiv1597771593ad p {
margin:0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mkp .ygrps-yiv-890692247yiv1597771593ad a {
color:#0000ff;text-decoration:none;}
#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-sponsor #ygrps-yiv-890692247yiv1597771593ygrp-lc {
font-family:Arial;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-sponsor #ygrps-yiv-890692247yiv1597771593ygrp-lc #ygrps-yiv-890692247yiv1597771593hd {
margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-sponsor #ygrps-yiv-890692247yiv1597771593ygrp-lc .ygrps-yiv-890692247yiv1597771593ad {
margin-bottom:10px;padding:0 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593actions {
font-family:Verdana;font-size:11px;padding:10px 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593activity {
background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593activity span {
font-weight:700;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593activity span:first-child {
text-transform:uppercase;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593activity span a {
color:#5085b6;text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593activity span span {
color:#ff7900;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593activity span .ygrps-yiv-890692247yiv1597771593underline {
text-decoration:underline;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593attach {
clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593attach div a {
text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593attach img {
border:none;padding-right:5px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593attach label {
display:block;margin-bottom:5px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593attach label a {
text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 blockquote {
margin:0 0 0 4px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593bold {
font-family:Arial;font-size:13px;font-weight:700;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593bold a {
text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 dd.ygrps-yiv-890692247yiv1597771593last p a {
font-family:Verdana;font-weight:700;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 dd.ygrps-yiv-890692247yiv1597771593last p span {
margin-right:10px;font-family:Verdana;font-weight:700;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 dd.ygrps-yiv-890692247yiv1597771593last p span.ygrps-yiv-890692247yiv1597771593yshortcuts {
margin-right:0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593attach-table div div a {
text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593attach-table {
width:400px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593file-title a, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593file-title a:active, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593file-title a:hover, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593file-title a:visited {
text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593photo-title a, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593photo-title a:active, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593photo-title a:hover, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div.ygrps-yiv-890692247yiv1597771593photo-title a:visited {
text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 div#ygrps-yiv-890692247yiv1597771593ygrp-mlmsg #ygrps-yiv-890692247yiv1597771593ygrp-msg p a span.ygrps-yiv-890692247yiv1597771593yshortcuts {
font-family:Verdana;font-size:10px;font-weight:normal;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593green {
color:#628c2a;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593MsoNormal {
margin:0 0 0 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 o {
font-size:0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593photos div {
float:left;width:72px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593photos div div {
border:1px solid #666666;height:62px;overflow:hidden;width:62px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593photos div label {
color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593reco-category {
font-size:77%;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593reco-desc {
font-size:77%;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 .ygrps-yiv-890692247yiv1597771593replbq {
margin:4px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-actbar div a:first-child {
margin-right:2px;padding-right:5px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mlmsg {
font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mlmsg table {
font-size:inherit;font:100%;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mlmsg select, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 input, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 textarea {
font:99% Arial, Helvetica, clean, sans-serif;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mlmsg pre, #ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 code {
font:115% monospace;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mlmsg * {
line-height:1.22em;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-mlmsg #ygrps-yiv-890692247yiv1597771593logo {
padding-bottom:10px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-msg p a {
font-family:Verdana;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-msg p#ygrps-yiv-890692247yiv1597771593attach-count span {
color:#1E66AE;font-weight:700;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-reco #ygrps-yiv-890692247yiv1597771593reco-head {
color:#ff7900;font-weight:700;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-reco {
margin-bottom:20px;padding:0px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-sponsor #ygrps-yiv-890692247yiv1597771593ov li a {
font-size:130%;text-decoration:none;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-sponsor #ygrps-yiv-890692247yiv1597771593ov li {
font-size:77%;list-style-type:square;padding:6px 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-sponsor #ygrps-yiv-890692247yiv1597771593ov ul {
margin:0;padding:0 0 0 8px;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-text {
font-family:Georgia;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-text p {
margin:0 0 1em 0;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-text tt {
font-size:120%;}

#ygrps-yiv-890692247 #ygrps-yiv-890692247yiv1597771593 #ygrps-yiv-890692247yiv1597771593ygrp-vital ul li:last-child {
border-right:none !important;}
#ygrps-yiv-890692247