diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php
index f2300dadb23e11ae16d1cd37e48ea083b48aa6de..9e71a0cd1a6b060cb5f7de27399c894b74dc74ed 100644
--- a/CRM/Case/Form/CaseView.php
+++ b/CRM/Case/Form/CaseView.php
@@ -425,7 +425,7 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form {
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
 
-    if (!empty($params['timeline_id']) && !empty($_POST['_qf_CaseView_next'])) {
+    if (!empty($params['timeline_id']) && $buttonName == '_qf_CaseView_next') {
       civicrm_api3('Case', 'addtimeline', [
         'case_id' => $this->_caseID,
         'timeline' => $params['timeline_id'],