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

InventUpd_Reservation filter on custom field in inventbatch

(0) ShareShare
ReportReport
Posted on by 65

Hi,

I have a technical issue with the reservation using filter on inventbatch. I have created an extension in inventbatch table and i i'd like to reserve the salesline filtering the quantity based on the field and not only for inventdtim. 

I would like to use the inventreservationcriteriabuilder but i don't know how to use with InventUpd_Reservation

Any ideas? 

thank you!

Michele

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

    Hi Michele,

    You can refer to the method of InventReservationCriteriaBuilder::newUpdate() to creates a new instance of the InventReservationCriteriaBuilder class for building a composite on-hand criteria for the given inventory reservation.

  • Suggested answer
    MB-05091058-0 Profile Picture
    65 on at

    Hi Judy,

    thank you but the solution works for InventUpd_reservation (in the updateReserveMore method) but in my solution the class is the InventUpd_WHSReservation that use strategies for search the batch...

    I found an article that i have used for my issue

    cloudblogs.microsoft.com/.../

    Here i share my solution

    I create an extension of the class whsInventBatchReserveQueryBuilder

    In this class I CoC for add the filter in the query ...

    Here my code:

    [ExtensionOf(classStr(whsInventBatchReserveQueryBuilder))]

    public final class whsInventBatchReserveQueryBuilder_MB9870_Extension

    {

       private VendAccount _VendAccount;

       private boolean _FilterByVendAccount = false;

       public VendAccount parmVendAccount(VendAccount _value = _VendAccount)

       {

           _VendAccount = _value;

           return _VendAccount;

       }

       public boolean parmFilterByVendAccount(boolean _value = _FilterByVendAccount)

       {

           _FilterByVendAccount = _value;

           return _FilterByVendAccount;

       }

       public Query buildOnHandQuery()

       {

           Query query = next buildOnHandQuery();

           if(_FilterByVendAccount && _VendAccount != "")

           {

               QueryBuildDataSource qbdsInventBatch = query.dataSourceTable(tableNum(InventBatch));

               qbdsInventBatch.addRange(fieldNum(InventBatch,VendAccount)).value(_VendAccount);

           }

           return query;

       }

    }

    and I use this method for call the reservation

    -------------------------------------------------------------------

       public void ReserveSalesLine(SalesLine salesLine, InventQty reserveQty)

       {

           InventUpd_Reservation   reservation;

           List                    strategyList;

           InventMovement          movement;

           movement = InventMovement::construct(salesLine);

           reservation = InventUpd_Reservation::newMovement(movement,-reserveQty, true, false);

           strategyList = new List(Types::Class);

           whsReservationHierarchyLevelStrategy marketStrategy =

               WHSReservationHierarchyLevelStrategy::newFromStrategyType(WHSReservationHierarchyLevelStrategyType::AllNotAllowedBlank,

               movement.inventTable(), movement.inventdim());

           strategyList.addEnd(marketStrategy);

           WHSReservationHierarchyLevel reservationHierarchyLevel = marketStrategy.getReservationHierarchyLevel();

           reservation.setWHSReservationHierarchyStrategyList(strategyList);

           // we could also take control of the queries used to find on-hand, for example adding some ordering on Status using :

           whsInventBatchReserveQueryBuilder query = whsInventBatchReserveQueryBuilder::construct();

           query.parmItemId(movement.itemId());

           query.parmInventDimCriteria(reservation.parmInventDimCriteria());

           query.parmInventDimParmCriteria(reservation.parmInventDimParm());

           query.parmReservationHierarchyLevel(reservationHierarchyLevel);

           query.parmIncludePhysical(true);

           query.parmVendAccount(salesLine.VendAccount);

           query.parmFilterByVendAccount(true);

           reservation.setWHSInventReserveQueryBuilder(query);

           //now we are reserving with all dimensions above location

           reservation.updateNow();

         }

    }

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 689

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 308 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans