I am overriding the Lead Convert functionality with a Visualforce page. Using custom extensions for the same. The functionality of the custom extension has been developed in such a way that, in the method, there is an if-else scenario, if being executed when everything goes fine, while else is being used up to show the error message to the users.
My requirement is to not to show any error message to the users. So whenever we enter in the else part, I want that I redirect back to the same vf page which called my apex method, and the same method be executed back again.
What I've done so far is creating a new PageReference and provided the URL of my Visualforce page again, but the on-load function of JavaScript is not calling the apex:actionFunction
to call that apex method again.
Can anyone Please provide any suggestion on that?
VF Code :
<apex:form >
<script type="text/javascript">
function load(){
recalc();
}
window.onload=load;
</script>
<apex:actionFunction name="recalc"
action="{!checkContvertAndRedirect}"
reRender="test"/>
Apex code for else part:
else {
System.debug('>>>>Entered in else>>>>');
//relatedListsNotFetched = 'NA';
//errorMsg = 'Something went Wrong. Please Try Again Later.';
return new PageReference('/apex/tdc_tlc__SingleLeadConvert?id='+lead.id+'&statusid=reloaded');
}