Redirect to editview from beforesave hook logic
I am trying to redirect from before save hook logic if an error occurs in it.It should redirect to edit view with error.I am using this code:
function ShowError($errorMsg,$beanID){
try{
SugarApplication::appendErrorMessage('An error has been occured: '.$errorMsg);
$params = array(
'module'=> 'ad123_Ads',
'action'=>'EditView',
'id' => $beanID
);
SugarApplication::redirect('index.php?' . http_build_query($params));
} catch (Exception $e) {
echo 'Caught exception: ', $e, "\n";
}
}
But the problem is after redirect all fields get unfilled.