Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

RE: How to post specific lines in a salesTable

$
0
0

Hi Samy,

public static void InvoiceSalesOrderAutomatically(SalesId _SalesId)
{
    SalesTable salesTable;
    SalesFormLetter salesFormLetter;
    Query query;
    QueryRun queryRun;
    QueryBuildDataSource qbds;
    ;

    try
    {
         ttsbegin;
            /*// Select the salesTable to update
            salesTable = SalesTable::find(_SalesId);
            // Create a new object of the SalesFormLetter_Invoice by using the construct-method in //SalesFormLetter
            invoice = SalesFormLetter::construct(DocumentStatus::Invoice);
            // Post the invoice of SO
            invoice.update(salesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None, false, true);
            // Set to true to print the invoice*/


            salesTable = SalesTable::find(_SalesId);

            query = new Query(QueryStr(SalesUpdatePackingSlip));
            qbds = query.dataSourceTable(tableNum(SalesLine));

            // Build query range to find those lines which needs to be posted.

            qbds.addRange(fieldNum(SalesLine, SalesId)).value(_SalesId);
            qbds.addRange(fieldNum(SalesLine, SalesStatus)).value(queryValue(SalesStatus::Backorder));
            //qbds.addRange(fieldNum(SalesLine, itemId)).value('P1');
            //qbds.addRange(fieldNum(SalesLine, RetailVariantId)).value('K1BR-00005');
            queryRun = new queryRun(query);

            salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
            salesFormLetter.chooseLinesQuery(queryRun);
            salesFormLetter.update(salesTable);
         ttsCommit;
    }
    catch (Exception::Deadlock)
    {
        retry;
    }

    catch (Exception::Error)
    {
        ttsAbort;
        throw error("Throwing exception inside transaction Invoice SalesOrder Automatically.");
    }
}



Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>