I created a textbox and a button. What I wanted to happen is that after pressing the button and the textbox is null, the focus must go back on textbox.
BEGIN
IF :blk.textbox IS NULL THEN
msg_alert('Error message', 'E', FALSE);
end if;
END;
I'd already tried to put the code above in WHEN-BUTTON-PRESSED trigger but nothing happens.
Put your code in WHEN-VALIDATE-ITEM trigger of :BLK.TEXTBOX item.
BEGIN
IF :blk.textbox IS NULL THEN
msg_alert('Error message', 'E', FALSE);
--if msg_alert procedure has no RAISE FORM_TRIGGER_FAILURE, then uncomment next line
-- RAISE FORM_TRIGGER_FAILURE;
end if;
END;
You can also set the MOUSE NAVIGATE property to FALSE (or NO) of the button so that the focus won't go to that button after it was clicked.
use GO_ITEM also to set the focus to the textitem. sample,
GO_ITEM('blk.textbox');
Why reinventing the wheel? Set text item's REQUIRED property to YES.
After reading comments you left for #eifla001's answer, I'm not sure what is the code you have. Something like this works properly on my Forms 10g (but should work on any version):
-- WHEN-BUTTON-PRESSED trigger
if :blk.textbox is null then
go_item('blk.textbox');
end if;
If it doesn't work, check TEXTBOX's properties. Is it really a text (or a display) item? Is it enabled? Are there any SET_ITEM_PROPERTY calls that make it unavailable?
Because, task you're about to perform is really trivial, that should work just like that.
Related
I have a form that contains a select list (:P10_DROPDOWN) that has its values defined via SQL:
SELECT
display_name,
value_id
FROM
vw_dropdown_options;
As a pre-render-before-header-process I have the following PL/SQL to pre-populate :P10_DROPDOWN:
begin
SELECT value_id
INTO :P10_DROPDOWN
FROM vw_dropdown_option_mapping
WHERE vw_dropdown_option_mapping_id = :P10_DROPDOWN_OPTION_MAPPING_ID;
end;
At this point my form appears on my page, and everything looks okay. However I need to have a custom procedure fire when a user clicks a button, so on a button on my page I defined an onClick event to fire this pl/sql block:
APEX_DEBUG.INFO ('P10_DROPDOWN_OPTION_MAPPING_ID ' || :10_DROPDOWN_OPTION_MAPPING_ID);
APEX_DEBUG.INFO ('P10_DROPDOWN ' || :P10_DROPDOWN);
NP_SAVE_MAPPING_VALUE (
DROPDOWN_OPTION_MAPPING_ID => :P10_DROPDOWN_OPTION_MAPPING_ID,
NEW_DROPDOWN_VALUE_ID => :P10_DROPDOWN
);
This is where I first notice my issue; the value logged out by the onClick for :P10_DROPDOWN is what was originally set via my pre-render-before-header-process, and not the value I select via my drop-down.
I have tried setting the source.used value on my dropdown to both "Always" and "Only". I have also replaced my pre-render-before-header-process with a source based single value SQL query. Neither is allowing my dropdown to change the session value via the dropdown.
Am I missing something about these session values?
I suspect that this is because newly selected value isn't in session state. To test it, create a SUBMIT button, push it, and then check the result again.
Just asking: did you consider
setting item's default value (instead of writing a process to pre-populate it)
using a dynamic action (instead of creating an onClick event)
I'm practicing oracle Forms, and I would like to know how I can to duplicate all values from a focused record. Do you have any idea? Thanks.
For example, I have actually my cursor focused in the record marked in yellow, I would like to click in "Duplicar" button (Duplicate in English) And then duplicate the actual record. How can i do that?
Click on the option insert new record, this will create an empty row just beneath the record you selected.
Then click on the duplicate record button, this will duplicate all the values from the row above in the row you just created.
If you want to be this automatic you can write a Key-duprec trigger in which you put the following code:
insert_record;
duplicate_record;
as much as i understand, you can perform these steps:
Firstly, you don't need to click on the duplicar button, use
WHEN-NEW-RECORD_INSTANCE trigger of comprobantes(master block).
In this trigger write this code:
declare
v_detail_blk varchar2(99) :='detalles';
begin
set_block_property(v_detail_blk,default_where,'cmp_no = '||:comprobantes.cmp_no);
go_block(v_detail_blk);
clear_block(no_validate);
execute_query;
end;
On the Duplicate button's when-button-pressed trigger you can call the built-ins create_record and then duplicate_record. This will insert a copy of the record that current;y has focus.
I have an Oracle APEX page that collects data via a classic report with apex_item dynamically generated items. Something like this:
select apex_item.radiogroup(qt.save_position, 1, qt.answer, null, null, null, null) col01
from xxpay_360_questions qt
where qt.questionnaire_id = 21
I then save the answers using a submit button that uses "Submit Page" and calls PL/SQL to insert/update the dynamically generated items from above. Something like this:
insert into xxpay_360_answers values (apex_application.g_user, APEX_APPLICATION.G_F01(1));
commit;
My question is how can I also do a transition to the next page of dynamically generated items (since I only have 50 apex variables to play with per page) when the submit button is clicked.
The submit button only has options for "Submit Page" and "Transition to Page" and not "Submit Page and then Transition to Page".
Is there a way of transitioning via PL/SQL as part of the submit code? Or is there an event that can transition after the page has been submitted?
Also how does this work with errors and the nice "Saved" fly over that apex has?
You need to create a Branch, on the after processing region:
Then you need to set as branch point: On Submit After Processing (After Computation, Validation and Processing) and the branch type as: Branch to page
Then specify the page number where your going to:
And finally you can set the branch to be fired only if one particular button is pressed and if one particular condition evaluates to true:
I think that would cover your needs.
But if you want to do it with PL/SQL you could do something like this:
Replace the page ID with the actual page Id to which you want to redirect the user.
BEGIN
IF(CONDITION)THEN
htp.init;
owa_util.redirect_url('f?p=&APP_ID.:10:&APP_SESSION.'); /*Replace 10 with actual Page Number*/
apex_application.stop_apex_engine;
ELSE
htp.init;
owa_util.redirect_url('f?p=&APP_ID.:20:&APP_SESSION.'); /*Replace 20 with actual Page Number*/
apex_application.stop_apex_engine;
END IF;
END;
Or you could use the APEX_UTIL.REDIRECT_URL procedure.
if you are using APEX 4.2 refer the APEX_UTIL reference from here.
You can use:
apex_util.redirect_url(
p_url => 'type your url here'
);
This effectively calls in the owa_util. redirect_url and automatically calls apex_application.stop_apex_engine.
how to change the block or form status to 'insert' in oracle forms 10g using when-button-pressed trigger. I want to do the same thing like the 'insert record' button in the default tool bar but using a custom button
any ideas?
Call do_key('create_record'); in your when-button-pressed trigger. This will insert a new record in the current block with all, what state changes accordingly.
Changing the state with set_record_property(:system.cursor_record, :system.cursor_block, state, 'INSERT'); will not bring the exact same result. But give it a try!
I have 2 data block 'Employee' as master and 'Employee_Details' as details and 1 control block for navigation. I have used my menu and usually the default developer toolbar was not appeared. So I place a Enter-Query button to serve the purpose. I used when-button-pressed trigger.
GO_BLOCK('EMPLOYEE');
IF :System.Mode = 'NORMAL' THEN
Enter_Query;
ELSE
EXECUTE_QUERY;
END IF;
In first trigger the Form goes to Enter-Query Mode. But when I pressed for Execute_Query it does not work. Rather it shows in status bar to press F8 to do query and Ctrl+q for cancel. I tried it to place the code in different button but not working. I do not want to press F8 for execute query. Why my button code not working for Executing Query? Have you any solution?
The problem probably is that there are a few options with your trigger.
One of them is if it will fire when in enter query mode.
Because you are in enter-query mode right now this switch should be true.
Then it will work.
The default for the switch is false, so no trigger will fire in enter-query mode.