You need to sign in to do that
Don't have an account?

Problem with action function oncomplete event
I am performing some validation on click of button
<apex:commandButton styleClass="cmdButton" style="background: green;" value="{!if(timesheet3.Status__c == 'To Be Approved','Verify Timesheet','Approve Timesheet')}" onclick="javascript:displayHoursPerWeekError('{!hoursPerWeekError}')" rerender="msg" />
function displayHoursPerWeekError(display)
{
if(display=='true')
{
var agree=confirm("Hours per week is less, are you sure you want to submit timesheet?");
if (agree)
{
approval();
return true ;
}
else
return false ;
}
else
{
alert('this');
approval();
return true;
}
}
If validation is true then I am calling submitApprove function at the controller using action function. Now after completing the request I need to get a property defined at controller to determing whether to close the window or not. But the alert('{!Test}'); prints blank although for testing purpose I am just returning false from this property.
<apex:actionFunction action="{!submitApprove}" oncomplete="Javascript:alert('{!Test}');if('{!closeWindow}' == 'true') {window.close();};" name="approval"/>
You should probably instead use a partial update:
I personally just return them to a new page whose only purpose is to close the window. Less fuss.
I am using console and we just want to close tab. No redirect / return to new page.