Sunday, February 10, 2019

Region only shown in development mode in Oracle APEX

In the last months, I had to look up several times in different projects how to show a region only when I was logged in into the App Builder in Oracle Application Express (APEX). So I thought to write a quick post on it.

In one project we had to log in with different users to test the behavior of the authorization schemes, so people saw the things they should see and could do the things they are allowed to do. As the logins where not straight forward we created a region with those test credentials. Other people were testing too with their own credentials, so we really wanted to keep the original login page, and decided to just add a region on the page we would only see when we were logged in into APEX itself.

Today I added some new pages to an app and wanted to make sure the navigation to those pages were only visible to me. I know, you should do this in DEV, and then when all is fine, propagate the app to TEST and PROD. The truth is, I've some applications that only exist in one environment and so I update straight in "production". Those apps are still backed up automatically every night, so worst case I can always take the version of the previous day. But just to be clear, this is not good practice ;)

So how do you show a region only when you are in development mode in Oracle APEX?

You go to the Conditions section of your region, list entry or any component in APEX really, and add a PL/SQL Expression: apex_application.g_edit_cookie_session_id is not null


Alternative you can use "Item / Column not null" and specify APP_BUILDER_SESSION:
*) updated blog post 11-FEB-2019 after comment of Christian (thanks Christian!)


It would be cool if there was a condition type "Development Mode", but maybe I'm the only one needing this...

Typically you would use Build Options (see Shared Components) to include or exclude certain functionality in your APEX app, but in the above two use cases, it won't really work.


Another enhancement would be that the Status of the Build option would include "Dev Only" next to Include and Exclude.

4 comments:

Stewart Stevens said...

Nice post, Dmitri.

Totally agree - developing on the Production system should be a NoNo.

I like the idea of a 3rd Build Opton. Have you or will you raise an ER for this?

Juergen Schuster said...

I disagree, developing in Prod IS an option. We have a very business critical app, C-Level management of a worldwide enterprise where we only develop in Prod. The CIO wants bug fixes and small CRs in hours. And you always have the real data. Creating and maintaining a 3 tier environment, DEV, TEST, PROD costs you 10 times as much and takes you 10 times as long. Not much benefit for APEX if 90% of the time is used for the organisational process keeping this cumbersome bureaucracy alive.

In APEX you can develop on a very fine grain level. New pages does not have to see anybody, same for new components of a page. For packages: just copy the original package with _2 do all your new stuff there and if it runs, copy it back to the original package.

Same customer other department with the classical 3 tier environment. Same CR costs you 10 times more in time and money. Just saying don't always follow the band wagon. Question old structures, think different ;-)

Chris said...

Hi Dimitri,

you can also use the substitution variable APP_BUILDER_SESSION, with a not null condition. I think we added that in 5.0, so it should be available in most projects.

Regards,
Christian

Dimitri Gielis said...

Thanks Christian, I knew it and forgot ... I've updated my blog post.

Thanks again,
Dimitri