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, ...
Unanswered

How to get the reservation of sales line

(0) ShareShare
ReportReport
Posted on by 573

Hi Experts,

Does anyone know how to get the reservation of sales line through X++, like inventory location, batch and quantity?

Thanks.

  • André Arnaud de Calavon Profile Picture
    307,097 Super User 2026 Season 2 on at

    Hi Bernardqin,

    This is not something we have to use daily. So I can't help you directly. You can have a look at the reservation form what logic is used to show the reservations. So, with some reverse engineering, you should be able to find out what x++ logic needs to be used to achieve your requirement.

  • HenryXie Profile Picture
    Microsoft Employee on at

    hi,

    this code can work in AX3.0 for your reference. 

    public static server void Svc_SalesLineReservation(RecId _recId
                                                        , InventDimId _dimId
                                                        , Qty _qty ,date _date = systemdateget())
            {
                InventTrans             l_invTrans;
                SalesLine               l_salesLine;
                InventMovement          l_inventMovement;
                InventUpd_Reservation   l_inventUpd_Reservation ;
                InventDim               l_invDim;
                SalesLine               l_line;
                InventSum               l_sum;
                ;
                 systemdateset(_date);
                try
                {
                    l_invDim = InventDim::find(_dimId);
           
                    ttsbegin;
                    l_line = SalesLine::findRecId(_recId,true);
                    if(!l_line.RecId)
                    {
                         throw error(strFmt("Can not find the line recID : %1",_recId));
                    }
                    l_sum = InventSum::find(l_line.ItemId,_dimId);
                    if(l_sum.AvailPhysical < _qty)
                    {
                          throw error(strFmt("There is not enough inventory onhand quantity (%8) for delivery (%9). SalesOrder : %1 ; LineNum : %2 ; Warehouse: %3 ; Location: %4 ; Batch: %5 ; Pallet: %6; Serial: %7 ;"
                            ,l_line.SalesId,l_line.LineNum,l_invDim.InventLocationId,l_invDim.wMSLocationId,l_invDim.inventBatchId,l_invDim.wMSPalletId,l_invDim.inventSerialId
                            ,l_sum.AvailPhysical,_qty));
                    }
                    l_line.RemainInventPhysical  = UnitConvert::qty(l_line.RemainSalesPhysical,
                                                         l_line.salesUnit,
                                                         l_line.inventTable().inventUnitId(),
                                                         l_line.itemId);
                    if(l_line.RemainInventPhysical < l_line.InventDeliverNow + _qty)
                    {
                        l_line.RemainInventPhysical = l_line.InventDeliverNow + _qty;
                        l_line.RemainSalesPhysical = UnitConvert::qty(l_line.RemainInventPhysical,
                                                         l_line.inventTable().inventUnitId(),
                                                         l_line.salesUnit,
                                                         l_line.itemId);
                    }
                    l_line.InventDeliverNow = l_line.InventDeliverNow + _qty;
                    l_line.SalesDeliverNow = UnitConvert::qty(l_line.InventDeliverNow,
                                                         l_line.inventTable().inventUnitId(),
                                                         l_line.salesUnit,
                                                         l_line.itemId);
                    l_line.update();
                    ttscommit;
                    l_inventMovement = InventMovement::construct(l_line);
                    l_inventUpd_Reservation =
                        InventUpd_Reservation::newInventDim(
                                    l_inventMovement
                                    ,l_invDim
                                    ,_qty * -1
                                );
                    l_inventUpd_Reservation.updatenow();
                        }
                catch (Exception::Deadlock)
                {
                    retry;
                }
            }

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 July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 415 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 374

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 365 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans