Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Q:Determine if a item value has changed

ATael-OracleMar 19 2013 — edited Mar 19 2013
Hello,
I am sure I am missing something basic but I just can't figure out how to do accomplish this.

I have a form with a radio button (Yes or No) which I need to determine in a Page Process if the user has changed the value to Yes or not. The result of this will decide if I am going to send an email or not.

I am running APEX 4.2.1.

Anyone?

Thanks
Andy
This post has been answered by Roel Hartman on Mar 19 2013
Jump to Answer

Comments

Roel Hartman
Answer
1. You can compare the current value (:Pxx_RADIO) with the value in the database
2. You can store the value on Page Load in another (duplicate) item and compare both of them
(3. You can do it in a database trigger - but some people advocate against that ;-) )
Marked as Answer by ATael-Oracle · Sep 27 2020
Howard (... in Training)
Can they change Yes/No only once per page submission? (You don't want to take action if they just keep toggling the control. Right?) If you want to capture each change you would have a Dynamic Action for that. But I'm sure you don't want that.

For once per page decisions, I typically save the initial value in a before header process:
:Pxx_RADIO_LAST := :Pxx_RADIO;
Then as Roel said, when you submit the page you can have an action to check if :Pxx_RADIO = :Pxx_RADIO_LAST and execute whatever process is needed.
ATael-Oracle
Need a little bit more information....
ATael-Oracle
You are correct, once per page descision is what I am trying to accomplish.

So, I create a PL/SQL process after the Fetch Row process and assign as you suggested
:Pxx_RADIO_LAST := :Pxx_RADIO;
But I am not sure how to create the item :Pxx_RADIO_LAST. I would assume it should be hidden but what should the source value be set to?

Thanks
Andy
Howard (... in Training)
You could always create an Application Item but I prefer to keep this one on the same page.

Yes, a Hidden Item. Hmm. I need to remind myself whether Hidden Items are saved in the Session State. It might not matter if you are only doing a local on-page test / computation. But try it out and I'll see if I can check on it.

Regards,
Howard
ATael-Oracle
Thanks,
so I created a Page item (copied it) and set it to hidden. As for source I am using Always replace any existing value in session but then I am not sure what to use for source type? I mean I don't want to assign anything as I am doing that in After Header Process (PL/SQL Anonymous block) and I can't find a way of doing that?

And I think that Hidden fields are saved in the session, I can see other items with values in the session debug which are Hidden.

--Andy

Edited by: A Tael on Mar 19, 2013 1:57 PM
I'm sure I left all that blank or defaulted. Since the value is assigned by a process, I believe none of that is required. But setting "always" as you did is generally good.

Howard
Howard (... in Training)
This always gives me grief. It's difficult to debug because 1) the Radio Group is not immediately saved in the session state AND 2) you cannot see the Hidden Item value on screen to know if your code is working. Here's what I recall.

1) You might want a Dynamic Action triggered by the event which is a change in the Radio Group. Use that DA to save the Radio group value in the session state. Otherwise, I'm afraid the :Pxx_RADIO value being tested might not be the current one -- i..e., the one in HTML that you see on the screen.

*** Edited by: Howard (... in Training) on Mar 19, 2013 3:17 PM (NOTE!)
We'll that will submit the whole page so I have to check what I've done before to just submi this item.

2) You might start with :Pxx_RADIO_LAST as a regular TEXT field so you can see it and do any verification and debugging. Then once it's working change to a Hidden Item or hide it with some Dynamic Action on Page Load.

I need to verify this ... busy today.

Howard
Howard (... in Training)
Okay.

1) For the Dynamic Action:
You want the Action to be "Execute PL/SQL Code".
Under Settings, in the code window just put the single "null;" satement.
Under Settings, for Page Items To Submit - Pxx_RADIO -- note - no colon here!
Under Setitngs, for Page Items to Return - Pxx_RADIO_LAST -- not no colon here!
(And don't put both Items on both line because that just causes a lock up when executed.)

2) The only down side is that if you display Pxx_RADIO_LAST, it will not show it's value until the Pxx_RADIO is change and the values is return in the Dynamic Action. But as soon as it's returned, it's the old value of Pxx_RADIO. And if Pxx_RADIO is toggled, Pxx_RADIO_LAST remains that initial value that it was when first set. If you want to see Pxx_RADIO_LAST on the screen when the page renders, I suppose tou need a DA to save it to the session state when it's set in the before header process.

If you want, look here on p. 5.

Workspace: SIMPLE_DEMOS
UN: hcarson at woh.rr.com
PW: SD123456789

RADIO_DEMO ID:25096
Dever / Ima9Dever

Page 3: Radio Group
Page 4: Checkbox
Page 5: Hidden Item Demo

To see that the value is saved, Set Radio Group to "Yes" and then go to p. 4. Go back to p.5 and "Yes" will be still be set but the Text Field -- I changed to Text from Hidden -- will be blank. When you click No, then the "Pxx_RADIO_LAST" value of Y will appear here. (Make sense?)

Howard
ATael-Oracle
Thanks! I will try this solution.

I have figured out that it has to do with the Radio Button to do (I think) as if I assign any other value to my XX_LAST Item it works like a charm.

--Andy
ATael-Oracle
I assume that your workspace are on apex.oracle.com? If so, the login credentials doesn't work....

--Andy
Someone else had a problem, too. Works for me. You're using @ for " at " of course. Have to go to dinner with boss! Later.

... Ah, maybe because I'm logged in! There can only be one(?) at a time. I guess. I'm off to dinner so try now!

Howard
A Tael wrote:
Thanks! I will try this solution.

I have figured out that it has to do with the Radio Button to do (I think) as if I assign any other value to my XX_LAST Item it works like a charm.

--Andy
Yes. Radio Groups are different. If I have it straight, the RG value is not immediately available to be tested or assigned like other items -- as you found out -- until the page is submitted. I described how to get around that (above) with a Dynamic Action.
1 - 13
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 16 2013
Added on Mar 19 2013
13 comments
3,063 views