+ Start a Discussion
chandrashekar Jangitichandrashekar Jangiti 

Hi i need to have help "I created VFpage and i return javascript like below but when am clicking on CANCEL and SAVE buttons it is not redirecting to Same record page

Hi i need to have help "I created VFpage and i return javascript like below but when am clicking on CANCEL and SAVE buttons it is not redirecting to Same record page.."

my script in VFpage:
<script language="JavaScript" type="text/javascript">
        function CloseAndRefresh(){
            window.opener.location.href="/{!$CurrentPage.parameters.OppId}"; 
            window.top.close();
            }
    </script>

and buttons:
<apex:commandButton action="{!saveCurrentStep}" value="Save" oncomplete="javascript:CloseAndRefresh()" status="Status"  />
            
           <apex:commandButton action="{!CancelCurentStep}" value="Cancel" oncomplete="javascript:CloseAndRefresh()"  />

So..here i need  below methods need to be execute..so i need below entire code foe save and cancel..
public void SaveCurrentStep(){
}
and 
public Void CancelCurentStep{
}

VamsiVamsi
Hi,

Is the Javascript keyword specifed intentionally in the below line ?

oncomplete="javascript:CloseAndRefresh()" 
chandrashekar Jangitichandrashekar Jangiti
Yes Vamsi..
 
VamsiVamsi
If you have your code in this way then it should work oncomplete="CloseAndRefresh();"