function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DIVYANSHU BHUSHANDIVYANSHU BHUSHAN 

Flow Salesforce

I need to show warning message when user close[X] the flow. It is working fine, but it is also showing warning message when click on the pause button and next button. This should not be happening.
 Here is my code :-
<apex:page standardController="Contact" extensions="ContactIntakeFlowController">
    <script type="text/javascript">
     window.onbeforeunload = function() {
       
        return "Did you save your stuff?"
      }
    </script>

<flow:interview name="ClientIntakeFlow_FROM_CONTACT" allowShowPause="true" finishLocation="{!PageA}" pausedInterviewId="{!pausedId}" rendered="{!displayBoolean}">
<apex:param name="ClientIdVar" value="{!Contact.Id}"/> </flow:interview>
    
</apex:page>

Thanks in advance :)
Swayam@SalesforceGuySwayam@SalesforceGuy
Hey, Use Below Code : Need Query For Bypassing unload event for those button
 
<apex:page standardController="Contact" extensions="ContactIntakeFlowController">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/>  
<script type="text/javascript">
window.onbeforeunload = function() {

return "Did you save your stuff?"
}

$(function () {
$(".FlowPauseBtn").click(function {
window.onbeforeunload = null;
});


$(".FlowNextBtn").click(function {
window.onbeforeunload = null;
});


});
</script>

<flow:interview name="ClientIntakeFlow_FROM_CONTACT" allowShowPause="true" finishLocation="{!PageA}" pausedInterviewId="{!pausedId}" rendered="{!displayBoolean}">
<apex:param name="ClientIdVar" value="{!Contact.Id}"/> </flow:interview>

</apex:page>

Let Me Know,  If it works don't forget to mark it as a best answer.

--
Regards,
Swayam
@Salesforceguy

 
DIVYANSHU BHUSHANDIVYANSHU BHUSHAN
Hello Swayam, the code you provided is not working :(
Swayam@SalesforceGuySwayam@SalesforceGuy
Hey Please try with this, Also let me know what error you are getting

<apex:page standardController="Contact" extensions="ContactIntakeFlowController">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/>  

<script type="text/javascript">
 
$(function () {
$(".FlowPauseBtn").click(function {
window.onbeforeunload = null;
});


$(".FlowNextBtn").click(function {
window.onbeforeunload = null;
});


});

window.onbeforeunload = confirmExit;
function confirmExit()
  {
    return "Did you save your stuff?";
  }
</script>

<flow:interview name="ClientIntakeFlow_FROM_CONTACT" allowShowPause="true" finishLocation="{!PageA}" pausedInterviewId="{!pausedId}" rendered="{!displayBoolean}">
<apex:param name="ClientIdVar" value="{!Contact.Id}"/> </flow:interview>

</apex:page>


--
Regards,
Swayam 
​@salesforceguy
DIVYANSHU BHUSHANDIVYANSHU BHUSHAN
Hey Swayam, I am not getting any error, but actually warning message is not coming when window is closed(Even Alert message is also not coming :( ). It is not coming at all. The other code is also not working. And really thanks for the help here.