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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Create Planned batch order through code X++ in D365 F&O

(0) ShareShare
ReportReport
Posted on by 758

Hi Everyone,

I want to create planned order through X++ code.

And whichever Item I select, its Route and BOM details should be get added in Route details of Planned order.

Please suggest how can I achieve the same. Thank you in advance.

pastedimage1622109999563v1.png

I have the same question (0)
  • huijij Profile Picture
    19,811 on at

    Hi Rhushikesh,

    When you select item num,its Route and BOM details will Correspond change to display in dropdown list then you can select one in the list.

    They are maybe a one-to-many relationship.

    7522._5563B783_.PNG

    And what your real Requirements?

    regards

  • Rhushikesh R Profile Picture
    758 on at

    Hi Judy,

    Actually my client has said, there will be only on Active BOM and Route for this particular items for which planned orders need to be created through code.

    So I just need to pick those Route and BOM details and have to create one planned order through code.

    But how can I generate it through code is blocker for me.

  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi Rhushikesh,

    To create a planned order based on the values filled in the dialog you can Call Method named createReqPO() of the class ReqTransPoCreate.

     /// 
        ///    Creates a planned order based on the values filled in the dialog.
        /// 
        /// 
        ///    true if the process did not throw an error; otherwise, false.
        /// 
        public boolean createReqPO()
        {
            ReqPO   saveReqPO;
            boolean createFailed;
    
            XDSServices xdsServices = new XDSServices();
            #DirParty
    
            if (!reqPO.RecId)
            {
                // save current buffer
                saveReqPO.data(reqPO);
    
                // create planned order
                try
                {
                    // Disable the DirPartyTable XDS policies by passing a non blank context string
                    xdsServices.setXDSContext(0, #SystemUser);
                    ReqPlannedOrder::construct().insertFromForm(reqPO,inventDim,fromInventLocationId,toInventLocationId,true,RecalculateBOMLevels.value());
                    // re-enable XDS policies
                    xdsServices.setXDSContext(0, '');
                }
                catch
                {
                    createFailed = true;
                }
    
                if (!createFailed)
                {
                    newReqPo.data(reqPO);
    
                    if (newReqPo.RecId)
                    {
                        element.closeOk();
                    }
                    else
                    {
                        // Due to firming time fence the planned order is already firmed and doesn't exists any longer
                        // -> validateWrite can't be executed
                        element.closeCancel();
                    }
                }
                else
                {
                    // restore buffer
                    reqPO.data(saveReqPO);
                }
            }
    
            return !createFailed;
        }

    Hope it help you.

    regards

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans