Search code examples
oracle-apex

How to load form without using a redirect URL (ORACLE APEX)?


I am practicing a form UI approach that I thought would be simple, but it is turning out to be quite the challenge.

The idea is to have two regions:

  1. Top Region: Sales Order Master
  • This region is hidden until a selection is made in the second/lower region.
  • It is a standard form region (so not IG)
  1. Lower Region: Sales Order List
  • This region is an Interactive Grid that shows all sales orders.
  • When clicking into a row within the grid, a hidden page item called :P2_SHOW_ORDER_ID is populated.
  • The setting of that page item is within a Dynamic Action that also shows or hides Region 1 based on it being NULL NOT or NULL respectively.
  • The idea is for the Region 1 to appear once a row is selected and provide the user the ability to edit the information.

I know if I have the click on the IG do a redirect to a new page that had Region 1 on it, and I linked the page items correctly, that I can get the record to populate, but my goal is to do this all within the same page.

I cannot figure out why loading a page using a redirect could get the form data to load, but that I cannot trigger it manually from within the page itself.

I have tried having the dynamic action also trigger a Form Initialization on Region 1, but that did not work. I even tried to hardcode the WHERE clause of Region 1 and it won't load any data. Only using the redirect feature will get the form to populate a record.

The purpose of the :P2_SHOW_ORDER_ID is that I thought if I placed it in the Region 1 WHERE clause it would pull that record upon refresh.

Does anyone know how to get a form to solve this problem?


Solution

  • Short Answer

    Make sure the primary key is set prior to a call to Form Initialization.

    Long Answer

    The form initialization process looks to be responsible for loading the data for edit or leaving it blank for insert. When a redirect URL is used, typically you populate the primary key column of the region and so when the initialization is performed, the application knows to load a record for edit as you've supplied a value for the primary key.

    If you try to set this value manually and simply refresh the region, it will not work. You have to set the primary key value and then use the Form Initialization as your refresh.

    You can set this up by having a computation that loads a global variable into your region's primary key. Make sure this is sequenced prior to the Initialize. This will have it load when you first enter the screen if the global is already set.

    If the page loads without the global set, thus loading in insert mode, my approach to load a record was having an interactive grid (or report) at the bottom where you click into a row to trigger it to load above.

    How ever you decide to trigger the event, you want to have it trigger a dynamic action with 2 actions:

    1. Set the value of the global from the record you selected.
    2. Submit the page. This will cause the page to reload and the compute and initialization combo will load your record.   In addition, if you don't want to use a global, you can skip setting up the computation and instead change DA action 1 to setting the primary key directly.

    Note that I still need to look into the logistics of this as I have to disable value protection to set the primary key. Not sure what I will run into once I start using the form.