separate action for [OK] and [IGNORE] button - oracle

in Oracle Apex I have a page where I want to edit individual records. To do this, the user selects a data record and then clicks the [OK] or [IGNORE] button. Here I have defined that the page is to be sent and then an update and insert takes place under PROCESSING. But he works "logically" one after the other. When I click [OK] an insert and update should take place and when I select [IGNORE] only an update without insert in a table should take place. Whats the best way to do this?

Process lets you create a Server-side condition which - additionally - offers you to choose which button it is related to.
Therefore, create two processes, each for its own button. Doing so, process will fire only when its button is pressed.

There are multiple options:
Create one page process per button and put a server side condition on each process (server side condition = When Button Pressed). Same answer as Littlefoot.
Create a single page process and in your source you manage the different cases. On submit, the value of the REQUEST is the name of your button. So your page process code could be
IF :REQUEST = 'OK' THEN
--code to execute when OK is pressed
ELSIF :REQUEST = 'IGNORE' THEN
--code to execute when OK is pressed
END IF;
You'd want to put a serverside condition on this of type "Request is contained in value" with a value of "OK;IGNORE". This will yield true if button OK or button IGNORE is pressed.

Related

How to disable the submit button for that session once the user submits the form in oracle apex?

I am creating an application on Oracle Apex version 18 that takes survey from users.
I have used form on table for that purpose. However, users are able to submit the form multiple times. Is there a way to freeze the submit button once the form is submitted?
Yes; you have to be able to find out whether it was already submitted (for example, record in a table gets its ID; or, survey_date gets is set to sysdate).
Then create a condition for that button. A simple option is to use a function body that returns Boolean, e.g.
return :P1_ID is null;
which will render the button only if :P1_ID item is empty. If it is not, you won't see the button any more.
In the first instance I would try setting the page attribute Enable duplicate page submissions to No.
It seems like you don't want users to be able to answer the same survey multiple times.
In order to achieve this you can use a server side condition as Littlefoot suggested, but you seem to have problems with setting up the server side condition properly.
If you use a hidden item on your page, which holds the value of the current survey the user has to answer like "P1_SURVEY_ID", you can add a server side condition that doesn't allow the user to answer it again, if he already has:
Type: No rows returned
SQL Query: select * from YOUR_SURVEYS where SURVEY_ID = :P1_SURVEY_ID;
This way the user can only click the button if he has not answered this specific survey yet.
This is a easy solution:
https://community.oracle.com/thread/4167853?start=15&tstart=0
Simply add the "Page Submit" TRUE Action to your Dynamic Action and
set the Show Processing "o Yes. Then you don't even need any Enable or
Disable Actions on your button.

How to run a process after page submit and before refresh

I am facing an issue in Oracle Apex (v5.1).
I have a dialog page that opens up from the parent page on clicking of an icon. On Closing the dialog page,my parent page submits on the event 'Dialog Closed'
and a process which runs on the processing of the submit of parent page which seems to be not working.
In that process,I have certain APEX_ITEMS whose values are being set on submit of the parent page. Is there any way to make the process run?
Extra Description : I have an Interactive report which is fetched from a table say 'Temp', the report has links in some of the columns.
When a user clicks the link he is redirected to a modal page (while setting an application variable say 'APP_VAR' to zero) and user can modify some data there.
In the modal page when user clicks 'Submit' button a process runs and updated the temp table and sets value of 'APP_VAR' to '1'
and then page is refreshed. On the same modal page there is a Dynamic Action written on 'Page Load' with server side condition of 'APP_VAR' = '1',
this Dynamic Action closes the modal page with 'Close Dialog' action.
Now when the modal page is closed on parent page there is a dynamic action written on 'Dialog Closed' event which submits the parent page.
Also there is a process 'Update Parent' on condition of 'APP_VAR' ='1' which updates the 'temp' table with all the values from parent page (As user
can change some of the values in the report.) and sets APP_VAR to 0.
All of this is done in order to keep the temp table updated with values from both pages.
But when modal page closes the parent page refreshes before 'Update Parent' process is completed leading to loss of any changes made in parent page.
How can I run 'Update Parent' before the page reloads? please keep in mind that before 'Update Parent' runs the report data needs to be submitted
to session state in order to get the updated data.
Case 1
Why do you not put the "Update Parent" process together with the dynamic action that submit the page? You would need two true actions in this dynamic action.
The first one would execute its PL / SQL "Update Parent".
The second would submit the page
or
Case 2
Or if you want to keep "Update Parent" in a process, just call it in the page submission (if necessary bind it to a button), put it in the correct order of execution (by setting the sequence number). In the dynamic action submitting the page define a button name for this submission (if necessary).
Example Case 2:
After closing the page I need to execute 3 processes. So, I link these 3 processes to a button, if necessary I put the conditions of the server.
After the submission:
10 - Process 1 (when I click the x button)
20 - Process 2 (when I click the x button)
30 - Process 3 (when I click the x button)
So I need to define in my dynamic action that submit page the name of the button associated with this submission (Fill in the "Request / Button Name" field).
*Hide this button.

Why is my Oracle APEX DML Form stuck in edit mode and not going back to create mode?

I have created a page based on "Form & Report" template. So there is the Report page on which there is the create button. That create button leads to the form page which contains.
It is pretty simple. I don't know if there is a cache memory not emptying itself or if there is a setting that I have not properly set.
When I want to create a new database record, Oracle Apex behaves as if I asked it to update a record (though it still presents me with empty text fields).
Below the image of what's happening.
Create button of the Report
Buttons for edit are shown when I click the create button
Those edit buttons are shown instead of the buttons below => This means that the Apex software is behaving like I asked to edit a record not to insert a record.
Why is this happening?
You need to take a look at your create button. Is it passing a value to the form? If so, you probably don't want that. Is it clearing the cache of the form? If not, you probably want to clear it.
Also, on the form page take a look at your processes.. specifically the Automated Row Fetch (ARF) process.. what's the primary key that this process is using?
Also, take a look at the conditions for each button on your form. For the delete/save buttons you likely want a condition type of "value of item / column in expression 1 Is NOT NULL".
For your create button you would want the opposite.. "value of item /... IS NULL".
In both cases for the expression 1 you'd want to use the item that your ARF is leveraging.
#Bloomberg58 if you used the wizard that should not have anyway try to validate the create button in report page and the server-side validation of create and save button in form page

Oracle Apex 5: How do I redirect page when (dynami-action)button clicked?

I have a dilemna. I want to redirect the APP_USER to another page when a button is clicked. The thing is the button has a dynamic action with PLSQL body. The PLSQL does a few checks and validations and then redirects the individual to another page. How would I do that? Many thanks.
I suggest you use Branches because they are easier and better from a security point of view.
On your page create a button that will submit the page (has attribute Action=Submit Page) then create a Branch at the Processing point where you will select the page that you want the user to be redirected to.
Now to make this branch run just in some conditions go to the Condition attribute of the branch and at When Button Pressed select your button and at Type select PLSQL Function Body and add your logic there or select some other type that suits you best.

Oracle APEX How to submit page with PL/SQL insert/update and then transition to next page

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.

Resources