0

I am trying to save and close a VF page on clicking 'Save' command button.Here's my code

<script type="text/javascript">
    function closewindow(){
        window.close();
        geopointe.api.closeAction();
    }
</script>

<apex:pageBlockButtons>
    <apex:commandButton value="Save" action="{!save}" oncomplete="closewindow();"/>
</apex:pageBlockButtons>

The issue here is oncomplete function is getting executed without saving the record and closing the popup.If I remove the autocomplete function then ,my code is working fine,running validations on page and then saving the record.Does anyone has an idea how can I perform the save before closing the window? Thanks in advance!

6
  • You'd need to use a Boolean property in apex class to know if the transaction was successful. If yes, close popup.
    – Raul
    Mar 13, 2018 at 6:32
  • This is not a duplicate.That solution is not working for me Mar 13, 2018 at 6:41
  • 1
    Could you share on what have you tried based on that answer, because that works.
    – Raul
    Mar 13, 2018 at 6:43
  • @RahulSharma Maybe it works for that specific situation, but doesn't work here for this situation. In this question, there aren't save errors, as far as the OP knows. Mar 13, 2018 at 16:06
  • Ah got it, @DeepikaRaina can you try adding rerender attribute and a page message to know if the save was succeeded without any error? Maybe add a working example which we can try?
    – Raul
    Mar 13, 2018 at 17:14

1 Answer 1

0

Please try the following way:

<apex:actionFunction name="quickSaveJavascript" action="{!quicksave}" oncomplete="window.top.close();"/>
<apex:commandButton value="Save" onclick="quickSaveJavascript();"/>
1
  • Not sure how this would help, care to elaborate?
    – Raul
    Mar 14, 2018 at 6:10

Not the answer you're looking for? Browse other questions tagged .