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

How to generate a batch number using batch job x++

(0) ShareShare
ReportReport
Posted on by

How can I generate a batch number in SalesLine using x++ job

pastedimage1622108269611v1.png

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at
    RE: How to generate a batch number using batch job x++

    Hi Ashraf_hk,

    You could get InventBatchId through InventTransOrigin table.

    Please check: community.dynamics.com/.../867529

  • Suggested answer
    Sumit Loya Profile Picture
    2,230 on at
    RE: How to generate a batch number using batch job x++

    Hi Ashraf,

    Generally on sales side, existing batch number is used. A new batch number is generally generated during  purchase. What is the need to generate new batch number for sales side? An existing batch number is generally selected while completing the picking process.

  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: How to generate a batch number using batch job x++

    SalesLine has InventDimId field, which is reference to InventDim table. And InventDim table has InventBatchId field, which is the value you see in the form.

    Values of InventBatchId field comes from InventBatch table. It's not clear if you want to use an existing value or create a new record in InventBatch table and use the newly created batch ID in InventDim. Please clarify.

    When working with InventDim table, set values (e.g. InventBatchId) and then call findOrCreate() method to eirher find existing record for the given combination, or to create a new one (with a new unique InventDimId). Then use this InventDimId in SalesLine.

    For example:

    InventDim inventDim = salesLine.inventDim(); // Current dimensions from SalesLine
    inventDim.InventBatchId = ...
    // Don't call update() on InventDim
    
    salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;

  • ergun sahin Profile Picture
    8,824 Moderator on at
    RE: How to generate a batch number using batch job x++

    Don't forget to create new record if there is no InventBatch record

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 883

#2
André Arnaud de Calavon Profile Picture

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

#3
Sagar Suman Profile Picture

Sagar Suman 228 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans