Imagine that you want to remove some record in a Query results in the “Select” functionality on the “Sales Quotation Edit Lines” Form during Sales Quotation Confirmation.
The records that will be removed are the sales quotation that don’t have an attachment.
Start from Sales quotation Table Form, click on sales quotation and click “Confirm”

“Sales Quotation Edit lines” form will be open.
Click on “Select”

A query form will be opened. Choose your filter and click OK


The sales quotation without attachments will be removed from query results and will be shown as info messages in the form.

How to do this in X++
Create an extension class (i.e. Al0_SalesQuotationEditLinesForm_Extension)
[ExtensionOf(classStr(SalesQuotationEditLinesForm))]
final class Al0_SalesQuotationEditLinesForm_Extension
{
//Variable to check if it's a confirmation
private boolean isConfirmation;
void chooseLines(SalesQuotationParmTable _salesQuotationParmTable)
{
next chooseLines(_salesQuotationParmTable);
isConfirmation = (this.documentStatus() == DocumentStatus::Confirmation);
if (isConfirmation)
{
if (!salesQuotationParmUpdate.LateSelection)
{
//Reset Query
chooseLines.reset();
QuotationId quotationIdCurr;
QuotationId quotationIdPrec;
while (chooseLines.next())
{
SalesQuotationTable localSalesQuotationTable = chooseLines.get(tableNum(SalesQuotationTable));
quotationIdCurr = localSalesQuotationTable.QuotationId;
SalesQuotationLine localSalesQuotationLine = chooseLines.get(tableNum(SalesQuotationLine));
CustName deliveryName = localSalesQuotationTable.DeliveryName;
LogisticsPostalAddressRecId deliveryAddress = localSalesQuotationTable.DeliveryPostalAddress;
CustDlvModeId dlvMode = localSalesQuotationTable.DlvMode;
if (!_salesQuotationParmTable.RecId ||
_salesQuotationParmTable.QuotationId != localSalesQuotationLine.QuotationId ||
_salesQuotationParmTable.DlvMode != dlvMode ||
_salesQuotationParmTable.DeliveryPostalAddress != deliveryAddress ||
_salesQuotationParmTable.DeliveryName != deliveryName)
{
_salesQuotationParmTable = SalesQuotationParmTable::findDeliveryInformation(salesQuotationParmUpdate.ParmId, localSalesQuotationLine.QuotationId, deliveryName, deliveryAddress, dlvMode);
}
//Check parameters
ProjParameters projParameters = ProjParameters::find();
str confirmationAttachment = projParameters.Al0DocuTypeIdAttachConfirmQuotation;
if(confirmationAttachment != '')
{
//Search if exists an attachment for SalesQuotationTable record
DocuRef docuRef;
select firstonly docuRef
where docuRef.RefTableId == tableNum(SalesQuotationTable)
&& docuRef.RefRecId == localSalesQuotationTable.RecId
&& docuRef.TypeId == projParameters.Al0DocuTypeIdAttachConfirmQuotation;
if(!docuRef)
{
if(quotationIdPrec != quotationIdCurr)
{
ttsbegin;
_salesQuotationParmTable.selectForUpdate(true);
_salesQuotationParmTable.delete();
ttscommit;
Info(strFmt("@Al0AM:Al0_0262_SalesQuotationsExclNoattach_01", quotationIdCurr, confirmationAttachment));
}
quotationIdPrec = quotationIdCurr;
}
}
}
}
}
}
}



