I have been chasing this one for a couple of weeks now, standard support directed me here.
I have 2 BPMs the first updates the TaxRates file from Vertex Data. That one works.
foreach (var County in Db.UD39.Where(County =>
County.Company == callContextClient.CurrentCompany &&
County.Key1 == callContextBpmData.ShortChar01 &&
County.Key2 == callContextBpmData.ShortChar02))
{
string tKey = County.Key1 + County.Key2 + "0000";
// this.PublishInfoMessage(tKey, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
if (callContextBpmData.Checkbox02)
{ // Use Tax rate has changed
if (callContextBpmData.Checkbox08)
{ // Eff Date change, make new record
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
var Rate = new Erp.Tables.TaxRate();
Rate.Company = County.Company;
Rate.TaxCode = tKey;
Rate.RateCode = "DEF";
Rate.EffectiveFrom = County.Date02;
Rate.RateType = 0;
Rate.TaxPercent = County.Number02;
Rate.CurrencyCode = "USD";
Rate.DeductPercent = 100;
Db.TaxRate.Insert(Rate);
Db.Validate();
txScope.Complete();
} // using txScope
} else
{ // Update existing rate
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
foreach (var Rate in Db.TaxRate.Where(Rate =>
Rate.Company == County.Company &&
Rate.TaxCode == tKey &&
Rate.RateCode == "DEF" &&
Rate.EffectiveFrom == County.Date02))
{
Rate.TaxPercent = County.Number02;
} // foreach Rate
Db.Validate();
txScope.Complete();
} // using TxScope
} // if Eff Date Changed
} // if Rate changed
}
Db.Validate();[/code]
Then a VERY similar BPM to update the TaxRgnSalesTax file, which does NOT work.
foreach (var County in Db.UD39.Where(County =>
County.Company == callContextClient.CurrentCompany &&
County.Key1 == callContextBpmData.ShortChar01 &&
County.Key2 == callContextBpmData.ShortChar02))
{
string tKey = County.Key1 + County.Key2 + "0000";
if (callContextBpmData.Checkbox05)
{ // if an override changed
decimal d = 0;
if (County.Number02 > 0)
{ // the rate must be more than 0 before Epicor can override it.
if (County.CheckBox02)
d = ((County.Number02 - County.Number12) / County.Number02);
} // if Use Tax > 0
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
foreach (var L in Db.TaxRgnSalesTax.Where(L =>
L.Company == County.Company &&
L.TaxCode == tKey))
{
L.ExemptPercent = d * 100;
L.ExemptType = 1;
} // foreach
Db.Validate();
txScope.Complete();
} // using TxScope
} // if an override changed
}
The 2nd BPM gets a server side error:
Server Side Exception
BPM runtime caught an unexpected exception of 'EntityException' type.
See more info in the Inner Exception section of Exception Details.
Exception caught in: Epicor.ServiceModel
Error Detail
============
Description: BPM runtime caught an unexpected exception of 'EntityException' type.
See more info in the Inner Exception section of Exception Details.
Inner Exception: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
Program: EntityFramework.dll
Method: EnlistTransaction
Original Exception Type: EntityException
Framework Method: A001_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A001_CustomCodeAction at offset 2217 in file:line:column <filename unknown>:0:0
Client Stack Trace
==================
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Ice.Proxy.BO.UD39Impl.Update(UD39DataSet ds)
at Ice.Adapters.UD39Adapter.OnUpdate()
at Ice.Lib.Framework.EpiBaseAdapter.Update()
at Script.UD40Form_BeforeToolClickForUD39(Object sender, BeforeToolClickEventArgs args)
at Ice.Lib.Framework.BeforeToolClickEventHandler.Invoke(Object sender, BeforeToolClickEventArgs e)
at Ice.Lib.Framework.EpiBaseForm.OnBeforeToolClick(String tKey, ToolClickEventArgs ea)
at Ice.Lib.Framework.EpiBaseForm.handleToolClick(String tKey, ToolClickEventArgs ea)
Inner Exception
===============
The underlying provider failed on EnlistTransaction.
Inner Exception
===============
The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
Inner Exception
===============
The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
Any ideas as to why the 2nd one generates that error? It occurs on
foreach (var L in Db.TaxRgnSalesTax.Where(L =>
L.Company == County.Company &&
L.TaxCode == tKey))
(I used info messages to figure that out)
Why is that creating an error when a very similar statement does not?
Sorry for the wall of text, the jist of it can be summed up 7 lines up