Skip to main content

Posts

Showing posts from 2021

Adding Copyright information to application export files

Oracle APEX 21.2 has introduced a new feature using which we can include copyright information in the application exports. There is a new application property Copyright Banner.  We can enter copyright text here. We can use substitution strings #APP_NAME# and #YEAR# in the copyright text. When writing copyright text into the export files, APEX will replace these substitution strings with respective values. #APP_NAME# will be replaced with the current application name and #YEAR# will be replaced with the current calendar year in YYYY format. So, let's enter some dummy text into Copyright Banner for testing. Name: #APP_NAME# All Rights Reserved. Copyright (c) 1999, #YEAR#, XYZ-Dummy Company. For further details please refer www.xyz-dummy.com/copyright Now, if we export the application, then we can see the below copyright information at the top of the application export file as below. Observe, substitution strings are replaced with their values in the generated copyright text.

Inline Attachments for Oracle APEX Emails

Prior to APEX 21.2, when you add any attachments to APEX email using apex_mail.add_attachment procedure, then those attachments are always added with  Content-Disposition as attachment . This behavior can be verified when we view the received emails as plain text, For e.g. refer to the below screenshot of an email taken using the "Show Original" option in the Gmail web client. APEX 21.2 has introduced a new feature that enables us to send attachments as inline attachments. There is a new parameter p_content_id added to apex_mail.add_attachment procedure. We can specify content_id for attachments and we can use this content_id to refer to the image in cid: scheme in img tags of HTML emails. In one of my previous blogposts, Including Images in Oracle APEX Emails , I have discussed a few options using which we can include images in emails. One of the options is attaching images to an email and referring to attached images by file name in cid: scheme. This works in deskt

Interactive Grid - Process Filtered Data on Server Side

Recently one of the APEX developers has reached out to me and asked if it's possible to capture filtered rows data of the Interactive Grid on the server-side and do some processing. In APEX 20.1, there is a new API APEX_IG , using which we can achieve this. Photo by Jakub Kapusnak on Unsplash The approach is very simple and straightforward. Get the internal region id based on the Static ID given for the IG region Get the last viewed report id based on region id Open query context for the region and report using region id and report id Fetch and loop through the rows using the query context Do something with fetched rows And finally, close the query context If you have already done this for interactive reports, then you should be already aware of these steps. The only difference here is, we use APEX_IG APIs instead of APEX_IR APIs. For the demo purpose, let's Build an Interactive Grid on EMP table and let's give it a Static ID as emp Create a Textarea page item with

SVG Pattern fill for Gantt Charts

In one of the previous applications I have developed, there was a requirement to show several types of entries in the Gantt chart and I must use visually distinct colors so it would be easy for users to understand which task bar is referring to which task type. Even though there are lot of different colors available technically, distinguishing nearby colors, without keeping them side by side is not easy. Users can recognize basic colors, beyond that it gets tricky. In such cases, we need something beyond colors to fill our charts. SVG Patterns SVG Patterns are somewhat similar to HTML5 templates. HTML5  template  tag can contain some HTML, but it will not be rendered when page is loaded. Later, we can use the  template  using JavaScript. In similar fashion, SVG Patterns holds graphic object, but it will not be rendered. However, the pattern can be used for other elements by referencing the pattern in the fill and/or stroke attributes. You can have quick look  here  to understand more a

Oracle APEX Tree Search

Implementing search feature for the tree region is little tricky. Consider we have tree region created on the employee table EMP  as below. If we search for employee JAMES and we want to show JAMES node, then we must show everyone up in the hierarchy till the root node, i.e. KING > BLAKE > JAMES. Luckily, we can easily get hierarchy (traverse path) using sys_connect_by_path .  For e.g. consider below query select ename, empno, mgr, sys_connect_by_path(empno, ':' )|| ':' as emp_path from emp start with mgr is null connect by prior empno = mgr order siblings by ename This query gives all employee rows from EMP table, along with path data, from the root node to current node. Now, we can use this path data to filter rows that are required to show any node. For e.g. we can use below query to get all the required nodes to show JAMES node. with emp_tree as ( select ename, empno, mgr, sys_connect_by

Interactive Grid - Freeze/Unfreeze Columns Using JavaScript

In Oracle APEX forums, there was a question about "how to conditionally unfreeze interactive grid columns based on the screen size". I had bookmarked this question on my blog notes. Because, this is a good candidate for blogpost as it's a common use case and it may be helpful for other developers.  Photo by Aaron Burden on Unsplash So, I have started building demo for this blogpost. Then, I found that freezing, unfreezing columns based on column name may not be the best solution, because whenever we change column order, then we need to change JavaScript code as-well. With further research (reading documentation thoroughly 😊), I found out that we can also pass column definition object while using freezeColumn and unfreezeColumn methods. This solves the problem with column names.  And then I did a little google search and found another similar question in APEX forums where John Snyders has provided a solution. This solution looks little different. Here, column propert

Handling JavaScript Errors - Part 2

In my previous blogpost, I have explained about JavaScript errors and how we can handle them in general and how we can handle them at application level. If you have not read it yet, you can read it here . In this blogpost, I will explain an approach to log JavaScript errors to a database table.  error event on window object provides lot of information. I found below information is useful for debugging and worth logging into DB. event.message : JavaScript error message event.filename : If source of the error is from a JavaScript file, then this will give full path of JavaScript file. If error is from inline JavaScript code written in APEX page, then this will give full APEX page URL including APEX session. event.lineno : Line number where error has occurred. Depending on event.filename, it could refer to line number from JavaScript file or from generated HTML page. event.colno : Column number where error has occurred. It should be read along with event.lineno . event.error.stack : Cal

Handling JavaScript Errors - Part 1

Before APEX version 5.0, there were only handful of documented JavaScript (JS) functions in APEX. Now, there are several JavaScript namespaces and hundreds of functions and methods available in Oracle APEX. From APEX 18.1, separate documentation section "JavaScript API Reference" is also added for JavaScript. So, it's evident that usage of JavaScript in APEX is increasing every day and with every release.  But, how are you handling JavaScript errors in your APEX applications? For server-side errors, we can use EXCEPTION block and we can also define "Error Handling Function" at application level. What about JavaScript code? Can we do something similar for JavaScript errors? In this blog, I am going to briefly explain about JavaScript errors and how we can handle them in general and how we can handle them at application level. Introduction Browsers have JavaScript engine inside them. Mozilla's TraceMonkey, Google's v8 are examples for JavaScript engines.