Forum Stats

  • 3,770,159 Users
  • 2,253,079 Discussions
  • 7,875,349 Comments

Discussions

Form with Popup LOV => after change in field save into session and use :field value for others

ChriReh
ChriReh Member Posts: 24
edited Jun 28, 2020 5:52AM in APEX Discussions

Hi all,

im a bit desperate. I googled and found lots of solutions that say "do it like this" and i tested and somehow they all dont work.

So currently i dont know if im having some really stupid mistake or is there some change how to handle this?

I provided a test application with test data - so everybody who wants to can check it out!

https://apex.oracle.com/pls/apex/f?p=4000:4500

Workspace: T_AOSAP

User: Demo

PW: Demo#123

The problem is Page 1001 - you can see under P1001_F_V_ID i already tried out a lot of different stuff...

Where i want it to work:

https://apex.oracle.com/pls/apex/f?p=99878:1000:

click Create (=> P1001) => choose "Vehicle" => Company shall be set based on to which Company the Vehicle belongs.

Im working on this since 2 days and somehow everything i try doesnt work.

Can you please give me a hint what im missing?

Kind regards

Chris

Tagged:
ChriReh

Best Answer

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,131 Red Diamond
    edited Apr 27, 2020 8:46AM Accepted Answer
    ChriReh wrote:Okay, out of what you built aroused a "Session protection violation" - i just leave it like this now.

    After fixing a couple of daft errors—I had the hidden item set as a database column, and the items in the wrong order in the Execute PL/SQL Code action—and reading up on the relevant JavaScript API (note what it says about Popup LOVs) it's now working properly.

    Add a hidden, unprotected page item called P1001_F_C_DISPLAY, and a dynamic action as follows:

    Event: Change

    Item: P1001_F_V_ID

    True Actions

    Action: Execute PL/SQL Code

    Items to Submit: P1001_F_V_ID

    Items to Return: P1001_F_C_DISPLAY, P1001_F_C_ID

    PL/SQL Code:

    begin  select      c_name    , c_id  into      :p1001_f_c_display    , :p1001_f_c_id  from      company c        join com_veh_link cvl          on c.c_id = cvl.cvl_c_id  where      cvl.cvl_v_id = :p1001_f_v_id;     end;

    Action: Execute JavaScript Code

    Code:

    var company = apex.item('P1001_F_C_ID');company.setValue(company.getValue(), $v('P1001_F_C_DISPLAY'));
«1

Answers

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,131 Red Diamond
    edited Apr 4, 2020 7:38AM
    ChriReh wrote:Hi all,im a bit desperate. I googled and found lots of solutions that say "do it like this" and i tested and somehow they all dont work.So currently i dont know if im having some really stupid mistake or is there some change how to handle this?I provided a test application with test data - so everybody who wants to can check it out!https://apex.oracle.com/pls/apex/f?p=4000:4500Workspace: T_AOSAPUser: DemoPW: Demo#123The problem is Page 1001 - you can see under P1001_F_V_ID i already tried out a lot of different stuff...Where i want it to work:https://apex.oracle.com/pls/apex/f?p=99878:1000:click Create (=> P1001) => choose "Vehicle" => Company shall be set based on to which Company the Vehicle belongs.Im working on this since 2 days and somehow everything i try doesnt work.Can you please give me a hint what im missing?

    By "do it like this" are you referring to the Neu dynamic action on page 1001? Always provide links to any tutorials, articles, or resources you have consulted.

    What version of APEX are you using?

  • ChriReh
    ChriReh Member Posts: 24
    edited Apr 4, 2020 8:17AM

    Hi fac,

    yes its about that.

    The tips are use a dynamic action to fetch the changed value in field and then submit the item to get it in session state.

    Its the Dynamic Action belonging to P1001_F_V_ID.

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,131 Red Diamond
    edited Apr 4, 2020 11:10AM
    ChriReh wrote:The tips are use a dynamic action to fetch the changed value in field and then submit the item to get it in session state.Its the Dynamic Action belonging to P1001_F_V_ID.

    These "tips" may be out of date. That's why I need to know where you found them and what version of APEX you are using.

  • ChriReh
    ChriReh Member Posts: 24
    edited Apr 4, 2020 11:38AM

    Im on Oracle Cloud, newest version, aswell as apex.oracle.com.

    One of the solutions was f.e. https://software.databasedevelop.com/article/13512080/Popup+LOV+selected+value+not+in+session+state

    But they all basically say the same, submit your item, whatever way and then it is in Session State.

    But this obviously doesnt work...

    I tried it via dynamic action on change of that object and then pl/sql code + submit item.

    I tried with dynamic action and "refresh region" giving the item as "items to submit" for the region...

    And yes, i fear maybe the way to do this changed and so the "old" solutions do no longer work.

  • ChriReh
    ChriReh Member Posts: 24
    edited Apr 5, 2020 9:28AM

    so just to clarify, its: Application Express 19.2.0.00.18

  • Tu Nguyen
    Tu Nguyen Member Posts: 112 Blue Ribbon
    edited Apr 5, 2020 12:04PM

    You don't need to set "Default value" for "Company"

    Your only problem is you forgot to pass "P1001_F_V_ID"  for "Item to summit" on "Set value" DA for Company.

    ChriReh
  • ChriReh
    ChriReh Member Posts: 24
    edited Apr 5, 2020 1:52PM

    Hi Tu,

    thanks for your post.

    I see, and i really wonder, it works now on application https://apex.oracle.com/pls/apex/f?p=108015:1001   [App: 108015]

    But it still doesnt work in https://apex.oracle.com/pls/apex/f?p=99878:1001  [99878]

    What am i missing? I rebuild the Dynamic action 100% the same (i think), i compared field by field.

    Sorry for making this trouble, but also in my oracle cloud environment it doesnt work with this... so there must be something else.

    ---

    EDIT:

    Okay nvm thank you for your help.

    I found the difference and the causing problem now.

    ---

    For P1001_F_C_ID i also have to activate the Switch "Manual entry" in "Settings" to transfer the value into it.

    So with this, everything works fine.

    ---

    But still, this values are not in Session state.

    i dont really need it in Session state now, because it will do what it should, but just because being curious...

    How do i get value from Popup LOV into Session State?

    Kind regards

    Chris

  • Tu Nguyen
    Tu Nguyen Member Posts: 112 Blue Ribbon
    edited Apr 5, 2020 3:01PM

    Item property: "Maintain Session State" must be set to "Per session" or "Per user", otherwise, the item would have no session state.

    For more information : https://docs.oracle.com/database/121/HTMDB/concept_ses_val.htm#HTMDB03013

    ChriReh
  • ChriReh
    ChriReh Member Posts: 24
    edited Apr 5, 2020 4:28PM

    One more problem arose out of the solution of the first

    2nd field is also a popup lov with an ID as Return Value, but the Name should be Display Value. (Statement: SELECT C_NAME D, C_ID R FROM COMPANY)

    Statement of the DA is:

    select  c_id

    from company

    join com_veh_link on com_veh_link.cvl_C_id = company.c_id

    where 1=1

    and com_veh_link.cvl_v_id = :P1001_F_V_ID

    I expected, that i select the ID in the DA (what is the necessary value for the Insert and the Return Value of my Popup LOV), but the Popup LOV will automatically use the corresponding Name for display (as selected in the Popup LOV).

    Well, it doesnt do it. It shows the ID - but this is not a value a customer will want to work with.

    Is there a way to handle this?

  • Tu Nguyen
    Tu Nguyen Member Posts: 112 Blue Ribbon
    edited Apr 6, 2020 1:09AM

    LOV does not work as your "expectation". You have to set the display name manually by javascript.

    ChriReh