My command button inserts a new record into the page. When I integrate oncomplete="formReset()"
, the page reloads and I can see the new record on the page.
function formReset(){window.location.href='/apex/pagename';}
With record creation, I also create an info message that the record has been created. But when there is an error, the page should not reload, as the error then would disappear. Therefore, I implemented a conditional oncomplete: oncomplete="if(!hasMessages(ApexPages.Severity.ERROR)){formReset()}"
Although there is no error, the page does not reload anymore. What is wrong here?