D365FO – AX – How to remove records from query results in Sales Quotation Edit lines (SalesQuotationEditLines)

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)

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
            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(quotationIdPrec != quotationIdCurr)
                            Info(strFmt("@Al0AM:Al0_0262_SalesQuotationsExclNoattach_01", quotationIdCurr, confirmationAttachment));
                        quotationIdPrec = quotationIdCurr;


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...