Monday 4 December 2023

Oracle APEX Classic report Card template - card link

 

Oracle APEX Classic report Card template - card link

Making your card be a link?

 
This one is more for my reference as it comes handy on many occasions.
 
You made a classic report with a card template based on a query and you want your card title link to be applied on card level?
Quick cookbook:
  1. create region based on a query
  2. pick one column and make it a link using column settings for example card_title
  3. Create After Refresh region Dynamic action and this JS to it
$('.t-Card-title a').each(function(index) {
   lnk = $(this).attr('href');
   
   $(this).closest('.t-Card-wrap')          
          .attr('data-href', lnk)
          .click(function(){
            window.location=$(this).attr('data-href');
          })
          .mouseover(function(){
            $(this).css('cursor', 'pointer');
          })
          .mouseleave(function(){
            $(this).css('cursor', 'default');
          })
});
Similar technique can be applied to IR report with different selectors. 
 
Happy APEXing,
Lino
 
 


Thursday 23 November 2023

Oracle APEX page Item type Number - Format and alignment vs Read Only

 

APEX page Item type Number - Format and alignment vs Read Only

Format is not respected and item changed alert triggers?

 
Here is the situation, you have a simple form with number fields. Imagine you have to make some read only vs some that need to be enter-able but right aligned.

We all know it is easy to do - you would go into the page and change item settings and move onto the next task. 

If you look closely you will notice that read-only field will encounter two issues. It does not format the number any more if you provided the format. 
 
Secondly, APEX also will not respect your Number Alignment setting. For example if you decide to right align your read only number item, it would still stay on the left side.

Fix for this part is easy. 

Formula is: 
  1. retrieve read only field from a DB as in required format with to_char()
  2. apply css style="text-align:end"
Of course you can put this in a .css file, apply a css class to your items and handle it in more manageable way.

Last bit we want to address is WarnOnUnsavedChanges message. 
 
In APEX 23.1 and APEX 23.2 (potentially earlier versions too) we noticed that after you make your item of a Number Type and you apply format mask, instantly you will get
 

warning message. Question is Why?

We are talking about a standard item type => Number item. You might think, here we go again, who knows what has been changed on the page and how do I detect which one of my last changes did this to try fixing it.

How do we detect what items have changed on the page so we can address the problem? There have been numerous blogs on this topic from Jeff Kemp, Martin D'Souza (link is broken) and Hayden Hudson on how to detect changes on the APEX page which might come in handy for you.

After playing around a bit you will pick that just because you configured your item to be of the Number type and you set some formatting on it, APEX page will start 'falsely' alerting you of a Unsaved Changes on this page. 

I say 'falsely' as this is not something we would expect as a result of a simple item setting change. Worst is if your end users pick this up.

Interestingly - if you do the same for example with a Date picker item type and you add formatting to it. WarnOnUnsavedChanges will not be triggered. 

Question is how do we fix this? Well this is still work in progress. 
 
For now you can apply similar logic as we did above for a read only number items. Or you can turn Warn on Unsaved Changes off.

Still it needs to be checked if this happens in 23.x version only or has it been there since number item type was introduced. 

Unfortunately, format mask does not work on Text Field types. 
 
Happy APEXing,
Lino
 
For my reference here  snippet from Hayden's code
var errors = [];

allItems = apex.page.forEachPageItem;
allItems(
    $("#wwvFlowForm"),
    function (el, name) {
      if (
        apex.item(name).isChanged() &&
   !apex.item(name).element[0].classList.value.includes("js-ignoreChange")
      ) {
        errors.push({
          message: "This item has unsaved changes",            location: "inline",
          pageItem: name,
        });
      }
    },
    true
  );

  apex.message.clearErrors();
  apex.message.showErrors(errors);

 
 

Thursday 2 November 2023

ORACLE APEX page item Text Case setting

ORACLE APEX page item Text Case setting

Value Placeholder text gets updated too - How to fix it?

We may argue that this is one of unwanted features of APEX 23.x but it is what it is. 

Here is the situation, you have a simple form with fields and someone asks you to impose a rule on one of the items that as soon as end users enters a value we want it to be upper or lower cased. 

Luckily there is a nice Item setting to help us with it called Text Case situated under Settings section
Image 
Only issue we found is that except doing what you expected making your input text upper or lower cased, it will also influence how your value place holder works which is maybe not what you wanted. 
To fix this you need to apply this CSS:
.apex-item-text::-webkit-input-placeholder { /* WebKit browsers */ text-transform: none; }

.apex-item-text:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ text-transform: none; }
.apex-item-text::-moz-placeholder { /* Mozilla Firefox 19+ */ text-transform: none; }
What basically happens is we are hitting the default behavior of how :placeholder works on an input. And APEX is simply inheriting it from there. 

Since this was not what we wanted this snipped of CSS code was helpful. 

Thanks to Jeff Kemp and Tim Kimberl for their feedback.
 
Happy APEXing,
Lino
 
 

Monday 2 October 2023

ORACLE APEX Application item with global scope

 

ORACLE APEX Application item with global scope

Sharing the value between two or more applications - How to?

Simple use case - we have two apps that share authentications and now we want to pass the application items value between these two. 

For a long time now APEX application definition had this feature where we can declare global application items. 

But what does it actually mean and how do we actually do this when there are more apps in place?!! 

Create an app, add an application item to it with a global scope. Have some way of setting this item to a certain value. So far so good. 

Okay now we can create a link to an app #2 where we will try to read this value out. 

Of course first thing we would need to do, is we need to set and align both Authentication Schemes to share their cookies. This way we do not get ask to re-login. We all knew this so far.

In application #2 create a region and simply reference globally set application item from an app 1 using substitution variable syntax. In my example this would be &APP_GLOBAL_ITEM. 


But if you run this.... nothing would happen. Or better said you would not get the expected value back. Question is why? 

In order to get this going the point is that you have to have the same application item created in both of these apps. Else it could leave you wondering what you have done wrong. 

Thanks Mark G. for bringing this to my attention and here is a reference to existing post with the same topic.

https://stackoverflow.com/questions/58065558/oracle-apex-how-to-access-application-items-with-global-scope-in-multiple-applic

Happy APEXing,

SLino

Wednesday 2 August 2023

Using this.triggeringElement in apex.item

ORACLE APEX Dynamic action - apex.item and this.triggeringElement

A perfect JavaScript expression usecase

If you ever wanted to trigger your DA based on an item that is a select list here is a quick read.

Scenario here is we want to trigger an action when item we interacted with contains a certain string like NBME in my case. How would we do this? 

To be 100% correct we want to check it against the item display value and not its return value (one hidden from the end users).

I strongly encourage you to visit apex.oracle.com/jsapi for a full reference of apis available to us. 

We all know about apex.item api which can easily give us the value of the item with something like apex.item("PX_TEST_CODE").getValue()

Problem here is that if we were to do this we would have gotten a value of return value from my select list item and not the one we are using as display. 

 

Fair enough we have also a function called displayValueFor() which sounds like our thing. 

If we pack it all together on our DA Client side condition we can do JavaScript expression with following code:

apex.item(this.triggeringElement)

 .displayValueFor(apex.item(this.triggeringElement).getValue())

            .includes('NBME')

What this will do is take our a return value of triggering element then it will get a display value of it in an item that is triggering it. At the end it will check it if it includes NBME string and return true or false as  a result of it all. 

It seemed I was coming back to it a few times so wanted to write it down somewhere.   

Happy APEXing,

SLino

 

Monday 3 July 2023

ORACLE APEX Security scan - APEX SERT 23.1

 

ORACLE APEX Security - APEX SERT 23.1

Free and easy security scanning tool for your Oracle APEX apps

Kscope has passed and I managed to get some time to do this. 

A new version of APEX SERT for APEX 23.1 has ben made available for download.

Anyone who is on APEX 23.1 version this is the SERT version you want to be on.

Install, share and provide feedback ;)

Happy APEXing,

SLino

 

p.s. will be working to get this onto the original repo soon

OraOpenSource/apex-sert

Monday 10 April 2023

ORACLE APEX Security - APEX SERT 22.2 download

ORACLE APEX Security - APEX SERT 22.2

Free and easy security scanning tool for your APEX apps

This time just a quick notice.... there is a new version of APEX SERT for APEX 22.2 available for download.

Anyone who is on APEX 22.2 version this is SERT version for you.

I also updated my original APEX SERT post with the same link. 

Install, share and provide feedback ;)

Happy APEXing,

SLino

Thursday 9 March 2023

Oracle APEX security - How to use APEX SERT

APEX SERT first run

How to run first Oracle APEX security scan using APEX SERT?

If you read my previous post your should be in solid place now where you are able to start APEX SERT for the first time. 

How do we do this? There is not much we need to do except log in into our APEX workspace.

Assuming here your installation worked, you should see a new link in your Application Builder.

Magic is that during an installation a special message is seeded on system level so that all developers should get this link once they login. 

If you simply click APEX SERT link it should spin up another tab with APEX SERT application. 

This means that you are all set to run your first security scan. Select an application and click Evaluate button. 

This is where all the fun begins!!!!!! 

Once this process is over you will be redirected to a dashboard. This is a place where we start reviewing all 'not so good' things in your app code.

Point is we need to get this score in the left side to be 100%. 

There is many ways and things we need to do before this will happen which includes reviewing all problematic places, changing your apps and re-running the evaluations. So have fun and hope you will learn how to make your apps more secure. ;)

Happy APEXing,

SLino

Monday 6 March 2023

Let's talk Oracle APEX Security - APEX SERT

APEX SERT installation notes

How to start using APEX SERT?

This time we will take a look at how to get APEX SERT installed and running. 

In its essence it should only come own to one script and you are ready to start using it.

If you downloaded installation scripts regardless of what version of APEX you are on you have be be aware that these versions must match each other. 

Meaning if you are running APEX 21.2 then you should install APEX SERT 21.2 and not any other. Why is this we will come to it later on? Point is that SERT simply will not run. Of course there is a way to tweak things and make it work but I am guessing we do not want lose time and want to get things going. 

Lets look at installation and how easiest to do this?

Download matching SERT version and unzip it somewhere. Find and open ins_auto_setup.sql 

This is the script I would recommend you to use, the only difference from ins.sql is that it will not prompt you anything so you can run it as one click install. At least that was the idea. 

In here you will notice this section

which is trying to explain all parameters we can provide as an input. Most are self explanatory.

There is a section with a basic example how you could call this script 

If you closer it will require of you to provide a sysadmin password, why is this? 

It will as part of the installation try to create users with a special access to some of APEX internal tables. In order to do this it needs to have admin privilege otherwise it would not work. Is this the best way to go or not is now out of scope for this blog post. ;)

Last section we need to be aware of is this one


As you can see here there are references to APEX versions etc.... 

Okay now you should be ready to install APEX SERT. If you execute the script and it all works for you should get few new schemas installed. 


Looking at them in top to bottom order.... 

  • SV_SERT_XXXXXX is a schema is the brain and all what APEX SERT does. All configs and everything is stored here in its tables
  • SV_SERT_APEX is a layer that has read access to SV_SERT_XXXXXX schema
  • SV_SERT_LAUNCHER is a special schema that holds up a REST API call which will actually start your APEX SERT application

With this quick fly-through of how installation looks like we can start scanning our apps for any security wholes. 


We will look at the first APEX SERT run in the next post.

Happy APEXing,

SLino