Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Custom Code to Iterate Through Sub-Records of Buffer Memory

Posted on by Microsoft Employee

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

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans