Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Grid byVBTool for SL 6.5 - from a view or join tables

Posted on by 70

I am trying to create a customized screen with a grid by VBTool for SL 6.5, from a view or join tables with three fields, custid, descr and BookingNbr. Table A is customer and Table B xBooking  is customized table but has fewer records than customer table.

The grid lists all customers but BookingNbr is blank if no records from xBooking, and new records can be inserted to xBooking table if user fill in the blank and click on Save.

 Anyone would have done similar customization? I would like to see example coding of this solution, thank you.

*This post is locked for comments

  • lukey Profile Picture
    lukey 70 on at
    Re: Grid byVBTool for SL 6.5 - from a view or join tables

    Thanks Barry, it makes sense and helpful.

    It would be wonderful if the grid can be added into customization instead of VBTool only.

  • Barry Flynn Profile Picture
    Barry Flynn 3,090 on at
    Re: Grid byVBTool for SL 6.5 - from a view or join tables

    I have a screen which does both.

    The grid, which is at level 2, has fields from a table and a view.

    I don't think there are any special rules for Views.

    They get treated exactly as if they were tables.

    (Solomon expects the final column of tables to be a tstamp column.

    So I do the same for Views - I have a rstamp as the last column.

    I don't know if that is actually required or not.)

    There are two SetAddr calls at level 2

       Call SetAddr(LEVEL2, "bXDDDoc", bXDDDoc, nXDDDoc, LenB(nXDDDoc))

       Call SetAddr(LEVEL2, "bXDGDD_v_ARDoc", bXDGDD_v_ARDoc, nXDGDD_v_ARDoc, LenB(nXDGDD_v_ARDoc))

    There is one SQLCursorEx call at level 2

    Note that only the table appears in the last parameter - only it gets updated.

       Call SqlCursorEx(csrXDDDocEtc, LEVEL2, "csrXDDDoc", "XDDDoc,XDGDD_v_ARDoc", "XDDDoc")

    The DetailSetUp call is

       garrDocs = detailsetup(csrXDDDocEtc, Spread1, PNULL, bXDDDoc, LenB(bXDDDoc), bXDGDD_v_ARDoc, LenB(bXDGDD_v_ARDoc), PNULL, 0, PNULL, 0)

    The grid's DBNav property contains a stored procedure (and several parameters).

    The proc starts off with

       Select * from XDDDoc X

       Join XDGDD_v_ARDoc A on

    So it selects columns from both the table and the View.

    I think  it may be a rule that the SQL matches the SetAddr calls.

    The first SetAddr call is for XDDDoc, and the proc selects it first.

    In this case, I want the table to get updated, but not the View.

    That works out well, because when there are multiple tables (and/or views) at the same level, the kernel will update only the first.

    Which is exactly what I wanted.

    If I did want the View to be updated, then I would have to write my own code (in the Update event, when the Level parameter = 2).

    Barry

  • lukey Profile Picture
    lukey 70 on at
    Re: Grid byVBTool for SL 6.5 - from a view or join tables

    Hi Barry,

    Thanks for this, however I like to see how the set up the grid for view or join tables. Because I cannot find description or samples from SAF_VT.

    How do I set up the the SetAddr and MemHandle? or do I need to SetAdd for customer table, and add on an extra column in its memory array for xBookingNbr after the detail grid setup in MemHandle = DetailSetup(..)?

    Cheers,

    Luke

  • Barry Flynn Profile Picture
    Barry Flynn 3,090 on at
    Re: Grid byVBTool for SL 6.5 - from a view or join tables

    If I am misunderstanding the question, please let me know.

    Are you saying that you want to totally prevent Inserts and Saves of the grid data?

    You can disable the SAVE button (and other "kernel" buttons) by putting one or more SetButton calls at the bottom of the Form1 Load event.

    You need to know what Level you want this to apply at.

    A sample of that call is

     Call SetButton(InsertButton + DeleteButton + NextButton + PreviousButton + FirstButton + LastButton + CurySelButton + CuryTogButton, LEVEL0, False)

    That disables all the listed buttons for Level 0.

    -----------

    Disabling the SAVE & INSERT buttons at the nominated Level should also prevent the Update event from firing at that Level.

    You can also prevent data from being Saved at a specific Level with code like this. I'm asuming that the Level you want to prevent from Saving/Inserting is Level 0

       if Level = Level0 then

           retval = NoAction

           exit sub

       end if

    Hope that helps...

    Barry

  • lukey Profile Picture
    lukey 70 on at
    Re: Grid byVBTool for SL 6.5 - from a view or join tables

    Thanks Barry,

    I don't want the kernel to do inserts into the xBooking table but add codes in Update event. I expect to see example  to code the grid for view or join tables which is not the one on one relationship like inventory and inventoryadg.

    Cheers,

    Luke

  • Barry Flynn Profile Picture
    Barry Flynn 3,090 on at
    Re: Grid byVBTool for SL 6.5 - from a view or join tables

    I'm not sure exactly what the problem is.

    Is it that you don't want the kernel to do Inserts into the xBooking table?

    Or is it the opposite - Inserts are not being made to that table, and you want Inserts to happen?

    Note that  the kernel will save one table at each screen level.

    So if you have two tables at, say, Level 0, then you must write code in the Update event to perform Saves for the second table.

    Note also that the Update event will fire multiple times. Ince for each Level being saved,and  once at the end. So if you are writing code in the Update event, you should look at the Level parameter and do you work at the correct time.

    Barry

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