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 :
Finance | Project Operations, Human Resources, ...
Answered

How to post only specific lines for sales order confirmation through code in d365fo

(0) ShareShare
ReportReport
Posted on by 25

Good morning,

I am trying to post sales order confirmation through x++. i can achieve that through salesformletter.update() but here i am having issue with lines.

I want to confirm only specific lines for example i have 3 lines i want to confirm only 2 lines.how can i specify while posting only to include 2 lines.

I have seen code in internet everywhere they use salesformletter.update().

I am trying to achieve this through salesparmtable and salesparmline insertion .

Please provide some light on this

I have the same question (0)
  • ggjhj Profile Picture
    25 on at

    Dear experts please provide some light on this

  • ggjhj Profile Picture
    25 on at

    Dear experts please provide some light on this

  • ggjhj Profile Picture
    25 on at

    Dear experts please provide some light on this

  • ggjhj Profile Picture
    25 on at

    Dear experts please provide some light on this

  • ggjhj Profile Picture
    25 on at

    Dear experts please provide some light on this

  • André Arnaud de Calavon Profile Picture
    305,815 Super User 2026 Season 1 on at

    Hi Ax2012,

    There is no need to continuously ask for updates. Note that this forum is monitored by volunteers, mostly spending their own spare time to answer questions.

    Order confirmations always require to have all lines and all quantities. There is no option from the user interface to deviate from this behavior. I wouldn't recommend trying to get a different behavior. For that reason, you must go for another implementation. Probably you can consider to split the order.

    Can you also tell the background of this requirement? Probably we can help you with a viable workaround.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Ax2012,

    We had done a customization some time back to select some lines for packing slip posting. I tried to change the code for sales order confirmation.

    You can try this code and see if this works for you.

    public void postConfirmation (SalesId _salesId)
    {
        salesFormLetter                 salesFormLetter;
        salesFormletterParmData         salesFormLetterParmData;        
        SalesFormLetter_Confirm         salesFormLetterConfirm;
        SalesParmTable                  salesParmTable;
        SalesParmLine                   salesParmLine, salesParmLineOrig;
        salesLine                       salesLine, salesLineUpd;
        salesParmUpdate                 salesParmUpdate;
        SalesTable                      salesTable;
        
        salesTable = SalesTable::find(_salesId);        
                     
        ttsbegin;
        salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Confirmation, VersioningUpdateType::Initial);
    
        salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
        salesFormLetterParmData.createData(false);
        salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
    
        salesParmTable.clear();
        salesParmTable.TransDate                = systemDateGet();
        salesParmTable.Ordering                 = DocumentStatus::Confirmation;
        salesParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
        salesParmTable.salesId                  = salesTable.salesId;
    
        salesParmTable.salesName                = salesTable.salesName;
        salesParmTable.DeliveryName             = salesTable.DeliveryName;
        salesParmTable.DeliveryPostalAddress    = salesTable.DeliveryPostalAddress;
        salesParmTable.CustAccount              = salesTable.CustAccount;
        salesParmTable.CurrencyCode             = salesTable.CurrencyCode;
        salesParmTable.InvoiceAccount           = salesTable.InvoiceAccount;
        salesParmTable.ParmId                   = salesParmUpdate.ParmId;
        salesParmTable.insert();
    
        // Change logic here for choosing the lines you need.
        while select salesLine
            where salesLine.SalesId         == _salesId
        {
            salesParmLine.initFromSalesLine(salesLine);
            salesParmLine.DeliverNow    = salesLine.SalesQty;
            salesParmLine.ParmId        = salesParmTable.ParmId;
            salesParmLine.TableRefId    = salesParmTable.TableRefId;
            salesParmLine.setQty(DocumentStatus::PackingSlip, false, true);
            salesParmLine.setLineAmount(salesLine);
            salesParmLine.insert();
        }
    
        salesFormLetterConfirm = salesFormLetter::construct(DocumentStatus::Confirmation);
        salesFormLetterConfirm .transDate(systemDateGet());
        salesFormLetterConfirm .proforma(false);
        salesFormLetterConfirm .specQty(salesUpdate::All);
        salesFormLetterConfirm .salesTable(salesTable);
        salesFormLetterConfirm .parmId(salesParmTable.ParmId);
        salesFormLetterConfirm .salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
        salesFormLetterConfirm .run();
       
        ttscommit;                 
    }

  • ggjhj Profile Picture
    25 on at

    Hi gunjan,

    Thank you so much the code is working.

    Regards,

    Have a nice day

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 503 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 487 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 433

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans