Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Custom Code to Iterate Through Sub-Records of Buffer Memory

(0) ShareShare
ReportReport
Posted on by

We are looking to do some advanced validation in the receipts screens which requires us to iterate through the inventory items on the receipt screen and subsequently iterate through the lot records on the associated Lot/Serial screen. I can get the code to run through the inventory item lines, but when I pull the data for the Lot/Serial records, it is only pulling the most recent line item.

For example:

  1. Invt Item A
    1. Lot A123
    2. Lot A456
  2. Invt Item B
    1. Lot B123
    2. Lot B456
    3. Lot B789

Although I can iterate through and get 2 records out of the main grid handle (A/B), each iteration of the lot/serial records only provides me the lots associated with the last inventory item I opened the Lot/Serial screen on. If I were simply concatenating a message box it would look something like the following if I had opened inventory item B Lot/Serial last.

Not sure what I'm missing on how to move the memory buffer for the sub-screen.

MESSAGE BOX

Inventory Item A, Lot B123, Lot B456, Lot B789;

Inventory Item B, Lot B123, Lot B456, Lot B789;

    GridHandle = GetGridHandle("Spread1")
    If GridHandle <> 0 Then
        Row = MGetRowNum(GridHandle)
    End If
    serr1 = MFirst(GridHandle, MaintFlag)
    While serr1 = 0
        Call GetBufferValue("bpotran.InvtID", strInvtID)
        strMsg = strMsg & "Inventory Item " & strInvtID
        LS_GridHandle = GetGridHandle("LS_Spread2")
        If LS_GridHandle <> 0 Then
            Row2 = MGetRowNum(LS_GridHandle)
        End If
        serr2 = MFirst(LS_GridHandle, MaintFlag)
        While serr2 = 0
            Call GetBufferValue("blotsert.LotSerNbr", theLot)
            strMsg = strMsg & ", Lot " & theLot"
            serr2 = MNext(LS_GridHandle, MaintFlag)
        Wend
        strMsg = strMsg & ";" & chr(10)
        serr1 = MNext(GridHandle, MaintFlag)
    Wend


*This post is locked for comments

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,925 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans