Refactors hookAfterSaveRecord.