I am doing some API calls in aftersave hooks logic.One thing i need to get the Id of saved record from DB to redirect user to edit view if any error occurs in hooks class. This my error code to redirect user but i need the record id:
function ShowError($errorMsg,$beanID){
try{
self::$already_ran = false;
SugarApplication::appendErrorMessage($errorMsg);
$params = array(
'module'=> 'ad123_Ads',
'return_module'=> 'ad123_Ads',
'action'=>'EditView',
'record' => $beanID
);
SugarApplication::redirect('index.php?' . http_build_query($params));
}
catch (Exception $e) {
echo 'Caught exception: ', $e, "\n";
}
}