Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Execute JavaScript on page load in a Template Component

InoLApr 17 2025

In a template component I have an Action button with an Action URL:

#action$readmore?title=&TITLE.

The Template Component has a JavaScript file

function executeOnLoad() {
 apex.actions.add([
   {
     name: 'readmore',
     Label: 'Read more',
     action: (event, element, args) => {
       apex.message.confirm("You want to know more about " + args.title);
       return true;
     },
   },
 ]);
}
document.addEventListener("DOMContentLoaded", executeOnLoad);

This raises an error:

Uncaught TypeError: apex.actions.add is not a function

If I call this executeOnLoad() via my page Execute When Page Loads, I don't get this error.

So, the Template Component JS code seems to run too soon, before all APEX JS is loaded.

Is there as solution for this, like a listener event that is even later than DOMContentLoaded?

This post has been answered by InoL on Apr 17 2025
Jump to Answer
Comments
Post Details
Added on Apr 17 2025
1 comment
74 views