Hi all!
I’m making a customization in the QuoteEntry (and OrderEntry) for deleting multiple lines.
I already created a custom field (Boolean) to flag the lines and a button in the Summary page to start the process.
Now the complicated part: the code.
Basically I wanted to do a for each for the orderdtl lines and if the lines has the custom field TRUE then the process will eliminate that line, along with others (if flagged).
I’m actually tryin to do this in a customization, cause I don’t want the code to be executed at the update, but only when the user requires it.
Can you help me elaborate some code that works in the customization?
I’d highly recommend taking a good read of the Epicor Customization guide available on EpicWeb to get started with form customization. I don’t know what prior knowledge you have with it but this would be a good place to start.
I tried to do that with a Pre-Process BPM (on Quote.Update)
but I’m missing something here too:
Erp.Tables.QuoteDtl QuoteDtl;
foreach (var QuoteDtl_iterator in (from QuoteDtl_Row in Db.QuoteDtl where
string.Compare(QuoteDtl_Row.Company, Session.CompanyID, true) == 0 &&
QuoteDtl_Row.QuoteNum == QuoteNum select QuoteDtl_Row))
if (QuoteDtl_iterator != null)
{
if(QuoteDtl_iterator.DeleteLine_c)
{
QuoteDtl = QuoteDtl_iterator;
Db.QuoteDtl.Delete(QuoteDtl_iterator);
}
}
When I try to save this BPM it trhows me this error:
There is at least one compilation error.
Update.CommonTypes.cs(283,33): error CS0433: The type ‘QuoteDtlTable’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.400.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.QuoteDtlSearch, Version=10.2.400.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
Update.Pre.test.cs(139,24): error CS0019: Operator ‘==’ cannot be applied to operands of type ‘bool’ and ‘string’
Update.CommonTypes.cs(88,55): error CS0433: The type ‘QuoteDtlRow’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.400.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.QuoteDtlSearch, Version=10.2.400.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
This example uses the WCF service to delete by quote line. Obviously you’ll need to modify to loop thru your rows but I’m just using single line for test
Take a look at this thread too:
var parameters = new Ice.Core.TaskParameterInformation(this.Db, taskNum);
var quoteNum = Convert.ToInt32(parameters.GetCharacterValue("TxtParam1"));
var quoteLine = Convert.ToInt32(parameters.GetCharacterValue("TxtParam2"));
//lookup quote and iterate
using(Erp.Contracts.QuoteSvcContract quoteSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.QuoteSvcContract>(Db))
{
//get your quotedata
var ts = quoteSvc.GetByID(quoteNum);
if(ts.QuoteDtl!=null)
{
//loop thru toQuoteDtl find your lines you want to delete
foreach(var line in ts.QuoteDtl)
{
if(line.QuoteLine == quoteLine)
{
//mark line for delete
line.RowMod = "D";
}
}
//QuoteCoParts
foreach(var line in ts.QuoteCoPart)
{
if(line.QuoteLine == quoteLine)
{
//mark line for delete
line.RowMod = "D";
}
}
//QuoteQty
foreach(var line in ts.QuoteQty)
{
if(line.QuoteLine == quoteLine)
{
//mark line for delete
line.RowMod = "D";
}
}
//Qtmmkup
foreach(var line in ts.Qtmmkup)
{
if(line.QuoteLine == quoteLine)
{
//mark line for delete
line.RowMod = "D";
}
}
quoteSvc.Update(ref ts);
}
}