Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL forum
Suggested answer

How to set the value of a field in a grid

Posted on by 340

We are trying to set the value of a field in the grid.  I tried MSet and SetObjectValue but they update the value of the field in all the rows and overwrites the previous update.

I have the code below, 

    Dim GridHandle As Integer

    GridHandle = GetGridHandle("Spread_CM")

    Dim liGridFetch As Integer

    Dim liMaintFlg As Integer

    Dim strInvtId As String

    liGridFetch = MFirst(GridHandle, liMaintFlg)

    Do While liGridFetch = 0

        ' The appropriate record from the array is now available in buffer

        strInvtId = GetObjectValue("ccmInvtID") (this works, I get the id for each row)

        QtyOnPO = GetQtyonPO(strInvtId)

        Call MSet("xQtyOnPO", QtyOnPO)   ( this updates all rows, tried setobjectvalue and still has the same issue)

        liGridFetch = MNext(GridHandle, liMaintFlg)

    Loop

  • Mark Asmus Profile Picture
    Mark Asmus on at
    RE: How to set the value of a field in a grid

    It depends on when you want your code executed... do you want the field set as soon as the screen appears?  Or only after selecting a vendor or po or other value?   Or both?  Based on this you would then put your code in the form1_load, or in the vendor Id check event, or PO number check event, etc...

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set the value of a field in a grid

    Good day...I have a question because I'm attempting to achieve something similar. In which event did you put your code? a chk event for a field,load event of the form on the grid

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set the value of a field in a grid

    Hi

    Obviously while we use the Setbuffervalue or getbuffervalue functions we need to define the setaddr in form load event with proper level.

    For your case you could define the setaddr for that user table as no level

    Thanks

  • RE: How to set the value of a field in a grid

    The solution you gave me helped me a lot but I had to use a different syntax.  I had to use setaddr and then a call to setbuffervalue. Since you mentioned user table buffer that made me think to use the setbuffervalue function.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set the value of a field in a grid

    No that is not Grid control name..

    I have mentioned the table name for sample purpose.

    You have to specify the buffer value for the control xQtyOnPO (Refer the Field Name Property for this control)

  • RE: How to set the value of a field in a grid

    We already tried setobjectvalue and it has the same issue.  I did set break point the GetQTyonPO function does return the correct value for each line.

  • RE: How to set the value of a field in a grid

    Is bxusertable the name of the grid?

  • RE: How to set the value of a field in a grid

    Hi Bharathy,

    Also, you will want to use setobjectvalue()

    If that is still setting all rows in the grid to the same value, I would be interested in seeing what the GetQtyonPO function is doing.   Maybe that is incorrectly returning the same QtyOnPO value for each line.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set the value of a field in a grid

    "bxusertable.QtyonPO=QtyOnPO"

    Note:

    Use your user-table buffer with appropriate column. I have mentioned above for just reference purpose.

    Thanks

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set the value of a field in a grid

    Hi Bharathy

    Try the below code and leave your feedback

       Do While liGridFetch = 0

           ' The appropriate record from the array is now available in buffer

           strInvtId = GetObjectValue("ccmInvtID")

           QtyOnPO = GetQtyonPO(strInvtId)

           bxusertable.QtyonPO=QtyOnPO

           Call MUpdate(GridHandle)

           liGridFetch = MNext(GridHandle, liMaintFlg)

       Loop

    Thanks

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,570 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,683 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans