Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Multiple Sales Order to a single sales Invoice in Ax2012.

Posted on by 235

Hi All,

Could, any one help me out through code how to post multiple so to a single sales invoice post and show saleseditlines form to user. In used the blow code but there are lot of chanes in Ax2012 in FormLetter Classes:

SalesFormLetter letter=SalesFormLetter::construct(DocumentStatus::Invoice);

    SalesParmLine   parmLine;

    salesLine       _salesLine;

    SalesParmTable  SalesParmTable;

    salesParmUpdate salesParmUpdate;

    SalesTable SalesTableMarked;

   ;

    ttsBegin;

    letter.transDate(systemDateGet());

    letter.multiForm(true);

    letter.specQty(SalesUpdate::All);

    letter.printFormLetter    (true);

   letter.createParmUpdate();

   select forupdate firstonly salesParmUpdate where

   salesParmUpdate.RecId == letter.salesParmUpdate().RecId;

   salesParmUpdate.SumBy = AccountOrder::Account;

   salesParmUpdate.update();

   letter.salesParmUpdate(salesParmUpdate);

   letter.initParameters(letter.salesParmUpdate(),  PrintOut::Current);

    if (SalesTable_ds.anyMarked())

    {

        SalesTableMarked  = SalesTable_ds.getFirst(1,false);

        while(SalesTableMarked)

        {

            letter.createParmTable(SalesParmTable, SalesTable::find(SalesTableMarked.SalesId));

            SalesParmTable.DocumentDate = SalesTable::find(SalesTableMarked.SalesId).DeliveryDate;

            SalesParmTable.Transdate = SalesTable::find(SalesTableMarked.SalesId).DeliveryDate;

            SalesParmTable.DocNumberingCode_LT = "P_SF1";

            SalesParmTable.insert();

            SalesParmTable.clear();

            while select  _salesLine where _salesLine.SalesId == SalesTableMarked.SalesId                letter.createParmLine(_salesLine); 

            SalesTableMarked =  SalesTable_ds.getNext();

        }

    }

    letter.run();

    ttscommit;

 

But, in Ax2012 there are SalesFormLetter , SalesFormLetterParmData, SalesFormLetterService , SalesFromLetterContract , SalesFormLetterController etc. classes to how to insert record in SalesParmUpdate , SalesParmTable and SalesParmLine Tables while posting...!

 

Thanks a lot...!!

Daxing

*This post is locked for comments

  • Menekse Profile Picture
    Menekse 110 on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    It is standart. Account receivable>Setup>Account receivable parameters>Summary update>Default values for summary update>Invoice account is chosen. Then post packing slip for multiple sales order

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    Hi KOD,

    Can you try my project for your request.  You can find download link below.

    https://mesutboztas.wordpress.com/2015/09/13/ax-2012-de-birden-cok-satis-siparis-satirinin-x-ile-tek-bir-irsaliyefaturada-nakledilebilmesi/

    [View:https://mesutboztas.wordpress.com/2015/09/13/ax-2012-de-birden-cok-satis-siparis-satirinin-x-ile-tek-bir-irsaliyefaturada-nakledilebilmesi/:550:50]

  • Kauto Profile Picture
    Kauto 2,650 on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    Guys, I have a similar issue to KOD - I want to simulate the Sales update summary posting form from salesEditLines form but I want to do it entirely by code - therefore Creating all the ParmTable and ParmLines records based on the query SalesUpdatePackingSlip - add ranges to this, run the query to select the lines, and then run the ARRANGE function to arrange by invoice account (this will be a variable I have declared).

    The reason I am doing this is that for some reason when we run summary update invoicing for multiple invoice accounts, if there are multiple deliveries on a single sales order line in the selection period - AX will not group the qty of these delivery note lines into 1 line - in other words there are two SalesParmLines created with the same inventTransId - this produces an error at posting and prevents the invoice account being invoiced.  The user then has to manually run summary update invoicing for each invoice account affected - this takes time and if it was automated through code from a table this would be a better solution.

    This is quite urgent and I'd appreciate anyone who knows that they are doing here.

  • RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    Yes Frederik. Its standard feature by symmary update

  • Fredrik Sætre Profile Picture
    Fredrik Sætre 12,644 on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    Not to be a Complete ignorant, but isn't this possible through the summary update feature?

  • NCarmona Profile Picture
    NCarmona 5 on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    Hi Kod, this is my solution

    void clicked()

    {

       SalesFormLetter     salesFormLetter;

       SalesTable          salesTable;

       SalesLine           salesLine;

       SalesParmTable      salesParmTable;

       SalesParmTable      salesParmTableNew;

       Object              callerFormDataSource;

       Common              record;//      = args.record();

       int                 parmEnum;//    = args.parmEnum();

       ParmId              parmId;

       ;

       salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);

       parmId = salesFormLetter.parmId();

       salesFormLetter.allowEmptyTable(salesFormLetter.initAllowEmptyTable(true));

       salesTable = SalesTable::find('PV020174762');

       salesFormLetter.salesTable(salesTable);

       callerFormDataSource = salesTable.dataSource();

       salesFormLetter.callerFormDataSource(callerFormDataSource);

       salesFormLetter.multiForm(true);

       salesFormLetter.getLast();

       salesFormLetter.parmId(parmId);

       salesFormLetter.transDate(systemDateGet());

       if (salesFormLetter.prompt())

       {

           salesFormLetter.run();

       }

    }

  • Kim Kopowski Profile Picture
    Kim Kopowski on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    in that case simply select multiple sales orders and pass it to the formletter.main via args (that is exactly what the standard Sales Order page does).

    I am not really getting what you try to achieve here....what is your business case for this?

  • KOD Profile Picture
    KOD 235 on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    HI Kim,

    The above code direclty posting the sales order to invoice but i need to show in the sales posting form (SalesEditLines - Form) in Ax2012.

    Thanks...!

  • Kim Kopowski Profile Picture
    Kim Kopowski on at
    RE: Multiple Sales Order to a single sales Invoice in Ax2012.

    a similar question has allready been answered here: https://community.dynamics.com/ax/f/33/p/106550/208931.aspx (Packing slip, more than one PO through x++)

    In an nutshell, you can do something like this:

    // 1) Build a query based on your Selection

    salesUpdateQuery.dataSourceTable(tableNum(salesTable)).addRange(fieldNum(salesTable,SalesId)).value(selectionStr);
    queryRun = new queryRun(salesUpdateQuery);


    // 2) call chooseLinesQuery Post the invoice for all Sales Orders
    salesFormLetter.chooseLinesQuery(queryRun);
    SalesFormLetter.update(
    salesTable,
    systemDateGet(),
    SalesUpdate::All,
    AccountOrder::None,
    NoYes::No,
    NoYes::no);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans