", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007erxQNSAY", "datePublished": "2024-10-08T16:42:41.000Z", "author": { "@type": "Person", "name": "Kundan Kumar Jha", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000FK8XKQA1", "affiliation": { "@type": "Organization", "name": "Infosys Limited" } } } ] } } Skip to main content

I have a command button("Send") for sending notification on a VF page, when I click the send button , it sends the notification, but the vf page popup doesn't get closed. On clicking the second time on the send button the vf page pop-up gets closed. In the first click only, it sends the notification using a flow but does not get closed. Below is the syntax,

 

<apex:commandButton value="Send" action="{!submitNotification}" onclick="handleSubmit()"/>

 

below is the script I have added it in vf page for closing the popup,

 

function handleSubmit() { 

console.log("Test inside handlesubmit1");

 if ({!isNotificationSent}) { 

console.log("Test inside handlesubmit"); 

closeLightbox(); 

 }

 return true; 

 }

 

Can anyone please guide, to resolve this.

 

 

#Salesforce Developer

1 Antwort
  1. 8. Okt. 2024, 16:42

    Hi,

     

    Try this,

     

    <apex:commandButton value="Send" action="{!submitNotification}" oncomplete="handleSubmit();" />

    <script>

    function handleSubmit() {

    console.log("Test inside handlesubmit1");

    // Check if the notification has been sent successfully

    if ({!isNotificationSent}) {

    console.log("Test inside handlesubmit");

    closeLightbox(); // Close the popup

    }

    }

    function closeLightbox() {

    // Your code to close the popup (depends on how you are handling the lightbox)

    console.log("Popup closed");

    // e.g. if you are using jQuery:

    // $("#yourPopupElement").hide();

    }

    </script>