4 Replies Latest reply on Oct 8, 2013 12:05 PM by jbante

    Best way to update tables not in current layout?


      (This is a purchase order application, but the same process would apply to a sales order, invoice, etc.)


      When receiving a purchase order, I need to update on-hand quantities in an items table and add records in a transaction log table. Neither of these tables is part of the PO layout.


      Currently what I am doing:

      - loop through the purchase order detail lines in the portal

      - set some variables with item number, quantity received, cost, etc.

      - open a new window

      - switch to a layout containing the table to update

      - search for the correct record (items table) or add new record (transaction log table)

      - update the appropriate fields

      - close the window


      This seems to work, but has lots of flashing on the screen as windows are created and closed. I think I have to open a new window, because if I switch to another layout in the current window, I lose my place in the portal I'm looping through. Is there a better way?

        • 1. Re: Best way to update tables not in current layout?



          Two things you can do to reduce flashing.  First use the Freeze window script step.  Second when you open the new windows set the distance from top to be  -10000 pixels.  This will put the new window off screen so the user doesn't see it or a flash when it appears and is closed.


          When you do this you may want to add a couple of scripts for use as a developer.  The first is a close window script.  Single script step, close window.  Use this if you abort the script and have the window off screen.  Next is a move window which moves the window to Distance from top of 10,  so you can see what is going on.


          Last thing I do for some of the this is create a pair of scripts that create and clear a global variable $$DEBUG.  When created is gets a value of 1.  I use this in the New window script step.  I put the formula if($$DEBUG; 10; -10000)  into the Distance from top field.  So when I am debugging I can see the window and when the user is running the script it is off screen.


          You don't mention which version of FM you are using.  Screen Flashing is/was a bigger issue in versions 11 and earlier.  Thats where I started with these techniques.  Version 12 improved the screen flash issue quite a bit.  



          • 2. Re: Best way to update tables not in current layout?

            Create a custom function which evaluates as -10000 if the user is not full access. If they are full access have 0 or blank. Use this as the x and y in the distance from window box.


            That way when you debug you can see the windows but the users can not.


            Also bear in mind the various SQL plugins allow you to perform actions with complete disregard of the current context.

            • 3. Re: Best way to update tables not in current layout?

              Thanks Bruce. FM12. And the flashing isn't bad, but when there are 10's of detail lines, it is noticeable. Mostly, I was just hoping I was ignorant and there is a better way. Opening the windows off screen makes sense. I should have thought of that. I do have a debug global variable and will do as you suggest for window placement -- good idea.

              • 4. Re: Best way to update tables not in current layout?

                Popping off-screen utility windows is fine for hiding flashing from desktop users. Be careful about moving windows around if this is a script you anticipate wanting to run server-side, where window moving and resizing is not supported.


                If performance ever becomes a problem, consider switching to a transactional processing method instead of switching layouts or opening new windows. Switching layouts and opening windows are relatively slow operations. You can select and manipulate related records by setting global key fields in the TO of the layout used in utility relationships to other TOs. You don't need any fields from these utility TOs to be on the layout.