Showing posts with label Apex. Show all posts
Showing posts with label Apex. Show all posts

Thursday, May 21, 2015

APEX - Error on sending email from DBMS_JOB in Apex

If we schedule a dbms_job that sends an email in Apex, we could encounter the following error:

ORA-20001: This procedure must be invoked from within an application session.

If you are using Apex_mail to send an email, the error will be of the form:

ORA-20001: This procedure must be invoked from within an application session. ORA-06512: at "APEX_050000.WWV_FLOW_MAIL", line 371 ORA-06512: at "APEX_050000.WWV_FLOW_MAIL", line 497 ORA-06512: at "APEX_050000.WWV_FLOW_MAIL", line 529 ORA-06512: at "APEX_050000.WWV_FLOW_MAIL_API"

This is because the context is not set and we are trying to send an email via APEX from DBMS_JOB.

We can set the context, we need to set the security group ID.

select workspace_id from apex_applications where application_id = :p_app_id;
  
You would know your application ID. 
 
apex_util.set_security_group_id(p_security_group_id => workspace_id);
  
You can put the above in a loop for multiple workspaces.
 
 

Tuesday, April 29, 2014

Apex - Clear a page when a tab is clicked.


How to clear a page when a tab is clicked?

Create a new application page process:
  • Navigate to Applications -> Shared Components -> Application Processes
  • Click Create
  • Create a process which runs “On Submit: After Page Submission – Before Computations and Validations”.

In Process Source put the following code:

DECLARE
l_tab_page_no NUMBER;

BEGIN
SELECT tab_page INTO l_tab_page_no
FROM apex_application_tabs
WHERE application_id = :APP_ID
AND tab_name = :REQUEST;

APEX_UTIL.CLEAR_PAGE_CACHE(l_tab_page_no);
EXCEPTION WHEN NO_DATA_FOUND THEN
    NULL;
END;

You can also do a specific Tab page (if you know the Tab name) using:

IF (:REQUEST = 'T_TAB_NAME’) THEN
   APEX_UTIL.CLEAR_PAGE_CACHE(your_page_number);
END IF;

Where T_TAB_NAME is your Tab name.

When you now click a tab, the page's cache will be cleared.

Have a look at Tab names and page # using the following query:
select * FROM apex_application_tabs;

Tuesday, February 4, 2014

Apex 4.0 Tabular Form - make Default add row checked (selected)

Apex 4.0 Tabular Form - make Default add row checked (selected)

How to make the row added using Add Row button default selected?

Steps:

  • Go to the page
  • Click on the Add Row Button
  • One can see that the Add Row button calls a java script addrow()
  • Add the following
$('input[name="f01"]:last').prop("checked", true);

Thus the URL target for  Add Row will be

javascript:addRow();
$('input[name="f01"]:last').prop("checked", true);


Type ahead feature - Text prompt

Type ahead feature - Text prompt

What is type ahead?
When you go to google and try to make a search, it prompts you for the nearest search option.
This is called type ahead.

Its now possible in Apex with a new item called "TextField with Autocomplete"

Steps:
- Create an item
- Select TextField with Autocomplet

Options:

Search: this defines how the search is performed, search for any character (contains) or match the characters exactly

Lazy Loading: Yes means the list will be read from the database every time the user types a character. No means the list will only be populated when the page is rendered

- Put in a query to get the data from a table.
 - Save

When you enter text in the textfield, you will see type ahead feature (prompting text)