Forum Stats

  • 3,815,486 Users
  • 2,259,041 Discussions
  • 7,893,135 Comments

Discussions

How to Bypass Message :This page is asking you to confirm that you want to leave?

PrakashC
PrakashC Member Posts: 20 Red Ribbon

Hi,

I have a page where I select a record from Interactive grid. There is a button in that region which has Dynamic Action. The DA has javascript which calls a process to prepare url (apex_util.prepare_url(apex_application.g_x01)

I am doing all this so that I can dynamically go to a specific page based on some logic. The page number is evaluated based on this logic.

All this works, however, I need to get rid of the warning pop up "This page is asking you to confirm that you want to leave......".

I have already set off the "Warn on unsaved changes" flag. Other than the IG, I have search field variables, which also have the "Warn on unsaved changes" set to ignore.

Is there a way I could get rid of the warning message?

Thank you in advance.


Prakash

Tagged:

Best Answer

  • Joe Upshaw
    Joe Upshaw Member Posts: 955 Silver Badge
    Answer ✓

    So, your block is always putting "No Changes to Cancel." In this case, you are calling apex.page.warnOnUnsavedChanges, i.e. do warn. Of course, then, you get the warning. So, apex.page.isChanged() isn't doing what you expect. Placing the command to turn it off above this if block doesn't help you because, within the if block, you turn it back on.

    Your original post was how to disable the warning. Get rid of the if block altogether and put in a call to apex.page.cancelWarnOnUnsavedChanges();. This should result in you no longer getting the warning and so; should satisfy as an answwer.

    As to your isChanged call. I suspect you are saving the changes and then calling this block. In which case, the method will return false. It only returns true if it finds changes that have been made "since last being sent to the server".

    -Joe

    StewStrykerNH

Answers

  • Hamza Al-abbasi
    Hamza Al-abbasi Member Posts: 529 Gold Trophy

    Hello PrakashC,

    Call this JS function before redirect to remove the handler that checks for unsaved changes :

    apex.page.cancelWarnOnUnsavedChanges();
    


  • PrakashC
    PrakashC Member Posts: 20 Red Ribbon

    Hi,

    Thank you for responding. Sorry I missed to mention that I have already tried that & it is not helping to resolve the issue.

    Here is a snapshot of my code, just in case I am going wrong somewhere


    try {

        var pg=2;

        console.log('url check...');

        apex.server.process("PREPARE_URL4TTS", {x01: urlstr}, {success : function(pData){

                                                                        if (pData.success === true) {

                                                                            if (apex.page.isChanged() == true) {

                                                                                apex.page.cancelWarnOnUnsavedChanges();

                                                                            } else {

                                                                                console.log('No changes to cancel');

                                                                                apex.page.warnOnUnsavedChanges("UnSavedChanges", fnIsChanged);

                                                                            }

                                                                            apex.navigation.redirect(pData.url);

                                                                        } else {

                                                                                console.log("inside false cond");

                                                                        }

                                                                    }, error: function(request,status,error){

                                                                        console.log("status---"+status+" error----"+error);

                                                                    }


                                                   }) ; 

        

          

        console.log('url check complete: ' );

    } catch(e) {

        console.log("Error: " + e);

    }


    My console.log always returns "No Changes to Cancel". I also just tried moving the "apex.page.cancelWarnOnUnsavedChanges();" above the if block, however, that did not seem to help either.


    Thank you again for your response.

    Prakash

  • Joe Upshaw
    Joe Upshaw Member Posts: 955 Silver Badge
    Answer ✓

    So, your block is always putting "No Changes to Cancel." In this case, you are calling apex.page.warnOnUnsavedChanges, i.e. do warn. Of course, then, you get the warning. So, apex.page.isChanged() isn't doing what you expect. Placing the command to turn it off above this if block doesn't help you because, within the if block, you turn it back on.

    Your original post was how to disable the warning. Get rid of the if block altogether and put in a call to apex.page.cancelWarnOnUnsavedChanges();. This should result in you no longer getting the warning and so; should satisfy as an answwer.

    As to your isChanged call. I suspect you are saving the changes and then calling this block. In which case, the method will return false. It only returns true if it finds changes that have been made "since last being sent to the server".

    -Joe

    StewStrykerNH
  • PrakashC
    PrakashC Member Posts: 20 Red Ribbon

    Thank you Joe,

    commenting out the rest of the code did help.



    try {

        var pg=2;

        console.log('url check...');

        apex.server.process("PREPARE_URL4TTS", {x01: urlstr}, {success : function(pData){

                                                                        if (pData.success === true) {

                                                                            /*if (apex.page.isChanged() == true) {

                                                                                apex.page.cancelWarnOnUnsavedChanges();

                                                                            } else {

                                                                                console.log('No changes to cancel');

                                                                                apex.page.warnOnUnsavedChanges("UnSavedChanges", fnIsChanged);

                                                                            }*/

                                                                            apex.page.cancelWarnOnUnsavedChanges(); 

                                                                            apex.navigation.redirect(pData.url);

                                                                        /*} else {

                                                                                console.log("inside false cond");*/

                                                                        }

                                                                    }, error: function(request,status,error){

                                                                        console.log("status---"+status+" error----"+error);

                                                                    }


                                                   }) ; 

        

          

        console.log('url check complete: ' );

    } catch(e) {

        console.log("Error: " + e);

    }

    Thank you once again.


    Prakash