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 :
Supply chain | Supply Chain Management, Commerce
Suggested Answer

How to link InventTrans with WHSWorkLine

(0) ShareShare
ReportReport
Posted on by 192
I need to create a batch job to post purchase order line product receipt only if all registered InventTrans has works completed for this purchase order line.
 
But I can't because there is no direct link between InventTrans and WHSWorkLine.  the system can only see 
work lines in purchase order line level ,not in InventTrans level. (Purchline.InventTransId=WHSWorkLine.InventTransId )
currently we don't use load to  link purchase order line with WHSWorkLine.
 
For example, I have a purchase order line of qty 5,
(1)scenario 1: qty 2 is registered and its warehouse work is completed, remained 3 is registered and its warehouse work is cancelled later.
(1)scenario 2: qty 2 is registered and its warehouse work is completed, remained 3 is registered and its warehouse work is cancelled ,and then I unregister , re-registered for this remained 3 and complete work.
The batch job can't tell the difference scenario 1 and 2. scenario 2 should be allowed to be posted.
I have the same question (0)
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    2,611 Super User 2026 Season 1 on at
     
    As you rightly mentioned, there is no direct link between InventTrans and WHSWorkLine in D365 SCM which creates ambiguity during partial registrations and work cancellations. 
     
    To answer the first part of the question you can leverage the below mentioned approach:
    InventTrans and WHSWorkLine can be linked through InventTransOrigin.
    - InventTrans and InventTransOrigin (InventTrans.InventTransOrigin == InventTransOrigin.RecId)
    - WHSWorkLine and InventTransOrigin (WHSWorkLine.InventTransId == InventTransOrigin.InventTransId)
    You can use the class InventMov_Purch::workLineExistsForInventTransId for validating the workLine against the inventory transaction id.
     
    The required conditions for posting the for the given InventTrans that are registered will be:
    For scenario 1 and scenario 2:
    1. Checking sum of WHSWorkLine.CompleteQty against the POLine that considers InventTrans.Qty registered (This query will be for work item lines that are completed and for purchase order lines that are registered). 
    2. Ignore the Work orderLines in status Cancelled or tied historically for Unregistered quantities. When the work lines are registered again then follow step number 1.
     
    For getting the registered list of items from Purchase order lines you can use
    //For Purchase Order Lines
    select sum(InventQty) from inventTrans
     where inventTrans.PurchLineRecId == purchLine.RecId
     && inventTrans.StatusReceipt == InventTransStatusReceipt::Registered;
     
    //For Work Order Lines - Would recommend using the Query model
    while select whsWorkLine
    join whsWorkTable on whsWorkTable.WorkId == whsWorkLine.WorkId
        where whsWorkLine.InventTransId == inventTrans.InventTransId
        && whsWorkLine.WorkStatus != whsWorkStatus::Closed
    {
      //For open lines skip posting
    }
    else
    {
    //Post the pending PO Lines 
    }
     
     
    Hope this helps. Happy to answer questions, if any.
     
     
     
     
     

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

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

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

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 126 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans