Delete multiple lines from Quote/Order

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).

foreach (var ttQuoteHedRow in ttQuoteHed)
{
foreach (var QuoteDtl_iterator in Db.QuoteDtl.Where(QuoteDtl_Row=> QuoteDtl_Row.Company == ttQuoteHedRow.Company && QuoteDtl_Row.QuoteNum == ttQuoteHedRow.QuoteNum))
{			
        if (QuoteDtl_iterator.DeleteLines_c = TRUE)
        {
            Db.QuoteDtl_iterator.Delete(QuoteDtl_iterator);
            Db.Validate(QuoteDtl_iterator);
        }
		Db.Validate();	
		txScope.Complete();		
}
}

But as you know this code won’t work.
It tells me that ‘The name ‘ttQuoteHed’ does not exist in the current context’.

Can someone help me please?
Thanks!

Are you trying to use this code inside of a form customization? This is BPM (server side) code and won’t work in a form customization.

If you are trying to do this via form customization, you’ll need an entirely different approach.

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 just need the method to pull the records from the QuoteDtl.
It’s just a condition check (boolean) on one custom field and then it deletes the line.

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’

I’d just join on QuoteDtl_Row.Company == Session.CompanyID instead of a string.Compare method

I did that, but it throws the same error on the save

Alright let me try to whip something up as an example, hold please.

Thanks!

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);
      }
}