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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

X++ code for sales return order line registration for all disposition codes

(0) ShareShare
ReportReport
Posted on by 32
Could you please provide the X++ code for sales return order line registration for all disposition codes in D365 F&O?
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    239,038 Most Valuable Professional on at
    Moved from Integration, Dataverse, and general topics forum.
  • Suggested answer
    Ramesh Kumar Profile Picture
    7,547 Super User 2026 Season 1 on at
    Hi,
     
    I hope below can help you.
     
    static void SalesReturnOrderRegistration(Args _args)
    {
        SalesReturnTable salesReturnTable;
        SalesReturnLine salesReturnLine;
        InventDispositionCode dispositionCode;
        CustVendDispute custVendDispute;
        DirPartyTable partyTable;
        CustVendGroup custVendGroup;
        CustTable custTable;
        CustVendTrans custVendTrans;
        
        // Create a new Sales Return Order
        ttsBegin;
        salesReturnTable.clear();
        salesReturnTable.initValue();
        salesReturnTable.SalesId = 'SR12345'; // Example Sales Return Order ID
        salesReturnTable.CustAccount = 'CUST001'; // Example Customer Account
        salesReturnTable.save();
        // Fetch all Disposition Codes
        while select * from dispositionCode
        {
            // For each disposition code, create a sales return line
            salesReturnLine.clear();
            salesReturnLine.initValue();
            salesReturnLine.SalesReturnOrder = salesReturnTable.SalesId; // Link line to return order
            salesReturnLine.ItemId = 'ITEM001'; // Example item
            salesReturnLine.QtyReturned = 10; // Example quantity returned
            salesReturnLine.DispositionCode = dispositionCode.DispositionCode;
            salesReturnLine.save();
        }
        ttsCommit;
        info("Sales return order and lines registered for all disposition codes.");
    }
     
    Thanks
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans