AnsweredAssumed Answered

how stop save Calls in logic_hook before_save? Sugar 7.6

Question asked by Rodolfo Jesus on Feb 12, 2016
Latest reply on May 1, 2016 by Alex Maras

I try it.

<?php
 class logic_hooks_class {
  function before_save_method($bean, $event, $arguments) {


  $bean->status = "Held";
  $call_id = $bean->id;


  $query =  "SELECT status FROM calls "; 
  $query .= "WHERE id = '".$call_id."' LIMIT 1";
  $results = $bean->db->query($query, true);
  $row = $bean->db->fetchByAssoc($results);
  $call_status = $row['status'];


  if($call_status == "Held"){
  SugarApplication::appendErrorMessage("{You can not edit  events with status Help!}");
  $urlParameters = array(
  'module' => "Calls",
  'action' => "DetailView",
  'record' => $call_id,
  );


  $url = 'index.php?' . http_build_query($urlParameters);


  SugarApplication::redirect($url);
  }
  }
 }
 ?>

 

But when I try to save a record. Sugarcrm show error.

 

 

Outcomes