Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to change Sales Line Batch Number

Posted on by 65

Hi all,

Need to make customization to change the batch number of sales line(on reserved inventory transactions) based on the customer group of the customer for him this sales order,if the customer belongs to certain group  will change sales line to pick from batches which have expire date after 6 months from now, Note sales order has automatic reservation

Any help will be appreciated

*This post is locked for comments

  • samehfcih Profile Picture
    samehfcih 65 on at
    RE: How to change Sales Line Batch Number

    Dear Sukrut Parab,

    If you can help me

    this sales order line

    batch5.png

     this batches sorted by expire Date

    batch7.png

    this invent transactions before putting code

    batch4.png

    this invent transactions after putting code

    batch5.png

    before putting code its default start from first expire date and continue

    and after putting code it start from batch we get based on the condition

    but when it's not enough back to first,

    need it to continue to next

    also I note that it not make sense to put batch number on sales line when it's reservation is automatic,

    so i think to change reservation from inventory side for that sales line but don't know how ,I'm really confused about this issue ,please advise me what should i do exactly as you can.

    many thanks for you effort 

  • samehfcih Profile Picture
    samehfcih 65 on at
    RE: How to change Sales Line Batch Number

    Dear Sukrut Parab,


    T2 is the start batch and is correct,sales order line has automatic reservation,it suppose automatically reserve from next batch(T1) ,but it back to first batch (022859), how can i solve this problem .

    Thanks a lot and Appreciate you effort

  • samehfcih Profile Picture
    samehfcih 65 on at
    RE: How to change Sales Line Batch Number

    Dear Sukrut Parab,

    this my code and I wrote it in the beginning of insert method of SalesLineType Class.

    /* Set Inventory Dimension Id*/

           if(CustGroup::find(salesLine.CustGroup).SixMonths){

           if(salesLine.Reservation==ItemReservation::Automatic){

                   select firstOnly inventBatch order by expDate asc where

                   inventBatch.itemId==salesLine.ItemId

                   && inventBatch.expDate>=today()+6*30;

                   inventDim.clear();

                   inventTable = InventTable::find(salesLine.ItemId);

                   inventDim.initFromInventTable(inventTable);

                   inventDim.inventBatchId= inventBatch.inventBatchId;//(your batch id based on

                   customer Group);

                   inventDim = InventDim::findOrCreate(inventDim);

                   salesLine.InventDimId = inventDim.inventDimId;

               }

           }

           /* End*/

  • samehfcih Profile Picture
    samehfcih 65 on at
    RE: How to change Sales Line Batch Number

    batch2.pngbatch2.pngbatch3.png

    Dear Sukrut Parab,

    I write the code you tell me
    kindly note that img1 is batches on the item sorted by expire date,and img2 is transactions reserved for sales line as you see it correctly start reservation from batch(T2) based on cust Group Customization we written,but I made sales line with 22 qty and Batch(T2) has only 20 qty ,it suppose to get remaining 2 qty from batch(T1) which has expire Date after (T2) ,but it get remainig from(022859) which is the first one,what should i do to made it get remaining from next batch not from the first.

    Thanks for you effort

  • samehfcih Profile Picture
    samehfcih 65 on at
    RE: How to change Sales Line Batch Number

    Hi Sukrut Parab ,

    Thanks a lot for your reply and your help, It's worked well for me ,but my in case I deal with automatic reservation sales order ,what is done is correctly reserve qty from specified batch based on CustGroup condition but when these batch not sufficient it complete reservation from first batch  .what I need is when qty for these batch all reserved get remaining quantity from the next one with expire date not get from first batch.

    Appreciate your effort

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans