Skip to main content

How to display image without page item reference in Oracle APEX

In this section, we'll learn how to display images in our Oracle APEX application without relying on a page item. This method is perfect for situations where we need to show an image directly from a database table column, a file, or a URL without first loading it into a specific page item. We'll cover how to achieve this using a dynamic action and a PL/SQL procedure, making our application more efficient and flexible. By the end of this tutorial, we'll be able to display images dynamically, improving the user experience and reducing page load times. This technique is useful for reports, dashboards, and custom user interfaces where a static page item isn't the best solution. You can vind a visual  solution  from here. STEP 1: Create a blank page. STEP 2: Create a region and set it properties like-          Name:                    Emp          Type:      ...

How to send SMS from Oracle APEX

 In today’s digitalized business solution world, SMS notifications are one of the fastest ways to reach users. Whether it’s for OTP (One-Time Password), reminders, or alerts, integrating SMS with your Oracle APEX application can add huge value. In this guide, we’ll walk through different ways to send SMS from Oracle APEX. For better understand follow this Tutorial in Youtube.


Why Send SMS from Oracle APEX?

Oracle APEX already provides built-in features for sending emails, but sometimes email isn’t enough. SMS can be useful for:

  • OTP & Two-factor Authentication

  • Order Confirmations Text

  • Notifications

  • Promotional Messages


Process to Send SMS in Oracle APEX

1. Register with Third Party SMS Gateway

Most SMS providers (like Twilio, Nexmo, or local telecom gateways) expose a REST API to send SMS. Oracle APEX supports REST integrations, so you can call these APIs directly.

Steps:

  1. Choose an SMS provider (e.g., Twilio, Nexmo, Clickatell, or your local telecom).

  2. Get your API credentials (API Key, SID, Auth Token, etc.).




2. Create Application Page To Send SMS

In this step you need to create a page to send SMS from your application. In my case, I have try to shown in two ways to send SMS. First, try to send SMS to a single receiver. And lastly shown how to send SMS to multiple users at a time.




3. Create AJAX Callback Process to Prepare Mobile No. Lists of Receivers

 Select process tab on the left side navigation pane and follow the below process-
1. select AJAX Callback.
2. Right Click here and select Create Process.
3. Paste the below code Source > PL/SQL Code in properties section-

        BEGIN

                apex_json.open_array;

                FOR I IN (

                        SELECT last_name

                                , phone_number

                                , ‘Dear ‘||last_name||’, ‘||chr(10)||’Your salary is BDT‘||salary||’ transferred to your bank.’||chr(10)||’Thank You’||chr(10)||’Payroll Section’ AS MSG

                        FROM employees

                        WHERE INSTR(‘:’||REPLACE(apex_application.g_x01,’,’,’:’)||’:’,’:’||employee_id||’:’) > 0

                ) LOOP

                        apex_json.open_object;

                        apex_json.write(‘NAME’, i.last_name);

                        apex_json.write(‘MOBILE’, i.phone_number);

                        apex_json.write(‘MSG’, i.msg);

                        apex_json.close_object;

                END LOOP;

                apex_json.close_all;

        END;

Note: Please replace appropriate single code in your pl/sql code editor.




4. Create Javascript Function to Execute AJAX Callback Process

Select page from the left side navigation pane. Select Javascript > Function and Grobal Variable Declaration. Open the code editor and paste the below code-
        function sendSms(msg, to) {
            var url = “Your API URL here"; // Must return json data
            data = new FormData()
            data.set('token', ‘Your TOKEN here')
            data.set('message', msg)
            data.set('to', to)

            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);

            xhr.send(data);
            xhr.onload = function() {
                var response = JSON.parse(this.responseText);
                console.log(response);
                apex.message.showPageSuccess(response[0].statusmsg);
            };
        }        



5. Create Dynamic Action to SEND_SMS button
Set the below properties for that dynamic action-

        a. Name-    Send Bulk SMS
        b. Change the true action
                Action- Execute Javascript Code
                Code - 
                            
var arr = [] ;
                            arr.push($v('P38_SELECTED_EMP'));

                            if (arr[0] != '') {
                                apex.server.process(
                                    'PREPARE_DATA'
                                    , {
                                        x01: $v('P38_SELECTED_EMP')
                                    }
                                   , {
                                        dataType: 'json' ,
                                        success: function(pData) {
                                            for (var i = 0; i < pData.length; i++) {
                                            sendSms(pData[i].MSG, pData[i].MOBILE);
                                    }
                                }
                            }
                        )
                    } else {
                        apex.message.showErrors(
                            [
                                {
                                    type: 'error' ,
                                    message: 'No employee selected to send SMS!' ,
                                    location: 'page',
                                    unsafe: false
                                }
                            ]
                        )
                    }

Conclusion

Sending SMS from Oracle APEX is straightforward if you use an SMS Gateway API like Twilio, Nexmo, or your local provider. By leveraging AJAX callback process and javascript function, you can easily send OTPs, alerts, and notifications from your APEX applications.

Start small with a test SMS, then integrate it into your workflows—your users will appreciate the instant updates! 


Comments

Post a Comment

Popular posts from this blog

How to preview & download files from database or local directory in Oracle APEX

 It is common for Oracle APEX developers to need to handle files. This blog post will show you how to preview and download files stored in a database or a local directory. The most common approach in Oracle APEX is to store files directly in the database, typically within a BLOB (Binary Large Object) column. The primary reason is that this method simplifies data management and backup. Sometimes, you may need to handle files stored directly on the server's file system rather than in the database. This is common for large files or when files are managed by other systems. We will cover the basic steps and code snippets required for each method. Before approaching this tutorial, you must need to cover ( preview image in large scale  and  save file into database/local directory ) these two tutorial. Step 1: Create a blank page and then create 3 regions. Set these three regions properties as like below- Region-1:     Name:           ...

How to integrate gmail and send email from Oracle APEX

Manually managing communications with vendors and customers in today's enterprise environment is a time-consuming and often inefficient process. Juggling emails, follow-ups, and notifications can quickly become overwhelming, leading to missed opportunities and delays. To streamline this critical aspect of business, it's essential to modernize your communication system. By integrating email directly into your business software, you can automate these interactions, ensuring timely and consistent communication without the manual effort. I have try to demonstrate step by step how to integrate gamil account with application in Oracle APEX. For better understanding, you can follow the email configuration system. Step 1: Create Access Control List (ACL). Connect your sys user and execute the below command- DECLARE     l_acl_path     VARCHAR2(3000); BEGIN     SELECT acl     INTO l_acl_path     FROM dba_network_acls     WHERE host = '*'...