web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Multiple Sales Order to a single sales Invoice in Ax2012.

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Kim Kopowski Profile Picture
    4 on at

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

  • KOD Profile Picture
    235 on at

    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
    4 on at

    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?

  • NCarmona Profile Picture
    5 on at

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

       }

    }

  • Fredrik Sætre Profile Picture
    12,644 on at

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

  • Rodrigo Pagliarini Machado Profile Picture
    on at

    Yes Frederik. Its standard feature by symmary update

  • Kauto Profile Picture
    2,724 on at

    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.

  • Suggested answer
    Community Member Profile Picture
    on at

    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]

  • Menekse Profile Picture
    110 on at

    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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans