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

Community site session details

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

Inventory Status Change with Specific Quantity

(2) ShareShare
ReportReport
Posted on by 52
Hello Guys,
I have a requirement related to Inventory status changes, where I need to update the status of a specific item using a batch job.
I am attempting to change the status (e.g., from Available to Damaged) for a particular quantity, but it is not working as expected.
For eg: If an item has 200 units available in the On-hand inventory, I want to change the status of 50 units to Damaged. After the update, the system should reflect 50 units as Damaged and the remaining 150 units as Available.
I’ve shared the code below—could you please help me resolve this?


Query query;
 WhsInventoryStatusConvert  whsInventoryStatusConvert  = WhsInventoryStatusConvert::construct();
 query = whsInventoryStatusConvert.buildQuery();
 SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(InventSum)), fieldNum(InventSum, InventLocationId)).value(stagingCaller.GLNInventWarehouse);  
 SysQuery::findOrCreateRange(_query.dataSourceTable(tableNum(InventSum)), fieldNum(InventSum, ItemId)).value(_line.ItemNumber);
 SysQuery::findOrCreateRange(_query.dataSourceTable(tableNum(InventSum)), fieldNum(InventSum, InventVersionId)).value(_line.InventVersionId);
 SysQuery::findOrCreateRange(_query.dataSourceTable(tableNum(InventSum)), fieldNum(InventSum, InventStatusId)).value(_line.FromInventoryStatus);
 SysQuery::findOrCreateRange(_query.dataSourceTable(tableNum(InventSum)), fieldNum(InventSum, InventBatchId)).value(_line.inventBatchId);
 SysQuery::findOrCreateRange(_query.dataSourceTable(tableNum(InventSum)), fieldNum(InventSum, PhysicalInvent)).value(SysQuery::value(_line.InventQty));
 _whsInventoryStatusConvert.parmQuery(_query);
 _whsInventoryStatusConvert.parmToStatus(_line.ToInventoryStatus);
   
 _whsInventoryStatusConvert.run();    
Categories:
I have the same question (1)
  • André Arnaud de Calavon Profile Picture
    297,629 Super User 2025 Season 2 on at
    Inventory Status Change with Specific Quantity
    Hi Tejeswar,

    Can you explain what you mean by "it is not working as expected"? Do you get an error message? 
    What are the stagingCaller and _line variables about? It looks like you try to filter on a record from the InventSum table where the PhysicalInvent is having a specific quantity as per your _line.InventQty variable. Do they match? If not the query result might be empty resulting possibly in no update at all.
     
    Please provide  more information so we are able to assist you.  

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 878 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 496 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans