This discussion is archived
10 Replies Latest reply: Sep 16, 2013 6:46 AM by Howard (... in Training) RSS

Deleting row from detail tabular form saves changes in master form

Nick4 Newbie
Currently Being Moderated

Hi All

 

Using APEX 4.2 on 11g.

 

I have a wizard generated Master Detail page (master form and detail tabular form on same page)

If I do this...

 

1. Edit a field in the master form, but don't save.

2. Delete an existing row from the detail tabular form with the 'Delete Checked' button.

3. Click 'Cancel' to leave page without saving.

 

The row has been deleted from the detail table, that's fair enough, but the changes made to the master have been saved.

This is confusing for the end users, I don't want this functionality. I only want my changes to the master form saved if I actually click the 'Save' button.

 

How do I make Delete Checked just delete the row from the detail table without affecting the master table?

 

Nick

  • 1. Re: Deleting row from detail tabular form saves changes in master form
    Tom Petrus Expert
    Currently Being Moderated

    Deleting rows from the tabular form submits the page, although I wouldn't think that the row process for the master record is actually saved since that only triggers from certain request values or the sql action set on a button. Are you sure the data is saved to the database and the field in the master form is not just saving session state (eg the source is not db column)?

  • 2. Re: Deleting row from detail tabular form saves changes in master form
    Paul Broughton Pro
    Currently Being Moderated

    HI Nick,

     

    If you add a condition to the Process on your page that is updating the Master Form normally called "Process Row Of ...

     

    The condition you need to add is the below presuming your allowing insert/update/delete on the master form:

     

    Condition Type:   Request is contained within Expression 1

     

    In Expression 1 field enter:  CREATE,SAVE,DELETE

     

    That way it will only be updated when either Create, Save, or the Delete from the Master Form are pressed and shouldn't be when delete in the tabular form is pressed.

     

    Thanks

     

    Paul

  • 3. Re: Deleting row from detail tabular form saves changes in master form
    Nick4 Newbie
    Currently Being Moderated

    TomPetrus wrote:

     

    Deleting rows from the tabular form submits the page, although I wouldn't think that the row process for the master record is actually saved since that only triggers from certain request values or the sql action set on a button. Are you sure the data is saved to the database and the field in the master form is not just saving session state (eg the source is not db column)?

     

    Yes. It is definitely saving to the db. This is not just a one off occurrence either, I can repeat this with any wizard generated master detail page on any pages I choose...

  • 4. Re: Deleting row from detail tabular form saves changes in master form
    Paul Broughton Pro
    Currently Being Moderated

    I think some of the older versions of APEX might have laid the Master Detail pages out slightly differently and not had the current behaviour but I managed to replicate your issue prior to my response so hopefully that should solve it.

     

    Thanks

     

    Paul

  • 5. Re: Deleting row from detail tabular form saves changes in master form
    Nick4 Newbie
    Currently Being Moderated

    PaulBroughton wrote:

     

    HI Nick,

     

    If you add a condition to the Process on your page that is updating the Master Form normally called "Process Row Of ...

     

    The condition you need to add is the below presuming your allowing insert/update/delete on the master form:

     

    Condition Type:   Request is contained within Expression 1

     

    In Expression 1 field enter:  CREATE,SAVE,DELETE

     

    That way it will only be updated when either Create, Save, or the Delete from the Master Form are pressed and shouldn't be when delete in the tabular form is pressed.

     

    Thanks

     

    Paul

     

    Hi Paul,

     

    Thanks for that, tried it and it certainly stops the changed master fields from being saved but now, because the page is submitted I guess, all the unsaved changes to the master form are lost. This is fine if you Cancel out, but not if you intend to save. So still not good...

  • 6. Re: Deleting row from detail tabular form saves changes in master form
    Tom Petrus Expert
    Currently Being Moderated

    Paul Broughton even though this is 4.2, don't row processes usually have the inherent request value check going on? For example, generating a report-form on apex.oracle.com will do this as I'd expect it to.

    Are these pages generated in older version, and which you are now once again working in? Just trying to understand this.

     

    @Nick4 Not much you can do about that out of the box. What happens is logical. You only save changes to the tabular form and not to the master record. Since those fields are set to retrieve their value from the database they will do so when the page is being rerendered after the submit, and not hold the submitted session state. It really is one or the other. If you want it better you might need to look into ajax processes to perform for the tabular form for example.

  • 7. Re: Deleting row from detail tabular form saves changes in master form
    Paul Broughton Pro
    Currently Being Moderated

    HI Nick,

     

    The only way I can rectify your problem is to do the following which will take a few steps:

     

    First of all you need to stop the Automated Row Fetch Firing, to do this:

    • Create a new branch that Firs When the Multi Row Delete Button is pressed, It should redirect to the same page, give it  Request Vale of MRD
    • Edit the Automatic Row Fetch on your page and add a condition - Request = Expression 1, In the Expression 1 field enter MRD

    After doing this when the page reloads none of the fields will be populated so we now need to make sure the values in session state are saved on the page.


    So to do this we need to go into each individul page item and change the source used:

    • Change all items source used from "Always, replacing any existing value in session state" to "Only when current value in session state is null"

     

    When the page delete is pressed now the page should reload and the previous values should still on the page.

     

    The final problem is now these values will always remain on the page unless they are cleared so the next thing we need to do is clear the cache of the page when any submit but MRD happens.  If you edit the branches on the page that redirect to that same page apart from the MRD one we just created and add the page number where it says clear cache.

     

    The other thing we need to do is clear the cache before we arrive at the page so in the report that links to the page for the link column in the column link section add the same page number it is navigating to.

     

    I hope all this make sense.  I would show you apex.oracle.com but its down for maintenance.

     

    Thanks

     

    Paul

  • 8. Re: Deleting row from detail tabular form saves changes in master form
    Paul Broughton Pro
    Currently Being Moderated

    Hi Tom,

     

    I was just casting my mind back and I think in 3.2 a master detail had one save button with the tabular form and one with the Master Form, this is no longer the case.  One Save Button is used to update both the Tabular Element and the Master now.

     

    Thanks

     

    Paul

  • 9. Re: Deleting row from detail tabular form saves changes in master form
    Nick4 Newbie
    Currently Being Moderated

    PaulBroughton wrote:

     

    HI Nick,

     

    The only way I can rectify your problem is to do the following which will take a few steps:

     

    First of all you need to stop the Automated Row Fetch Firing, to do this:

    • Create a new branch that Firs When the Multi Row Delete Button is pressed, It should redirect to the same page, give it  Request Vale of MRD
    • Edit the Automatic Row Fetch on your page and add a condition - Request = Expression 1, In the Expression 1 field enter MRD

    After doing this when the page reloads none of the fields will be populated so we now need to make sure the values in session state are saved on the page.


    So to do this we need to go into each individul page item and change the source used:

    • Change all items source used from "Always, replacing any existing value in session state" to "Only when current value in session state is null"

     

    When the page delete is pressed now the page should reload and the previous values should still on the page.

     

    The final problem is now these values will always remain on the page unless they are cleared so the next thing we need to do is clear the cache of the page when any submit but MRD happens.  If you edit the branches on the page that redirect to that same page apart from the MRD one we just created and add the page number where it says clear cache.

     

    The other thing we need to do is clear the cache before we arrive at the page so in the report that links to the page for the link column in the column link section add the same page number it is navigating to.

     

    I hope all this make sense.  I would show you apex.oracle.com but its down for maintenance.

     

    Thanks

     

    Paul

    Thanks Paul

     

    I tried that but found that the master page items are never populated with any data. The row fetch would need to happen when the page first loads wouldn't it?? The condition might need to include the initial page load...

     

    My plan might be to tell the users that it is either... 'the unsaved master data will be lost when you delete from the detail form', or, 'the unsaved master data will be saved...'. They can decide which and adjust their processes...

     

    Nick

  • 10. Re: Deleting row from detail tabular form saves changes in master form
    Howard (... in Training) Pro
    Currently Being Moderated

    A (hopefully enlightening) comment for those not so advanced in what is going on here APEX-wise.

     

    What I see: The "processing model" for what is trying to be accomplished:

         a. Do operations on the Master independent of the Detail, and

        b. Do operations on the Detail independent of the Master.

     

    We want any pending (i.e., incomplete) operations of the Master to remain as they are when the Detail updates.  I term this an "intermediate" state because data has been changed in the Master web form but these changes have not be submitted.  This is an unstable (unsaved) state.

     

    Doing Detail form operations when the Master form in this "intermediate" state, violate the APEX "processing model".  APEX isn't currently designed to do the above.

     

    Trying to do the equivalent of the above has caused me grief.  The APEX model assumes the Master is in a "saved/stable" state so that any operations which cause a page submit, and hence cause(s) data to be refreshed, don't change the state.  But if the Master data is in an "intermediate" state (i.e., with data changed but not saved/submitted), submits for the Detail form cause this data (the current values of the Master data in the web form) to be lost.

     

    So, what can be done about it?  My solution has been to place the Detail form on a separate page and perhaps bring it up as a popup window.  Each technique has its own unique features (i.e., challenges/problems).

     

    I hope this helps someone.

    Howard

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points