logic hooks popup alert

Hello,

Please help me solution to display popup alert by logic hooks

This logic hooks after save of Case, when Case set to Closed but Task in subpanel is not Completed, the logic hooks will popup alert and restrict save.

Thanks 

Parents Reply Children
  • Note that you won't be able to do it in an after_save logic hook as the Case bean would already be updated with the new values.

    Additionally, if the above doesn't work, try using sugar_die("your message here")

  • Hi Bhavesh Patel

    This is my logic hooks

    <?php

    class CheckClosed
    {
    public function CheckTask(SugarBean $bean, $event, $args)
    {
    global $sugar_config, $db,$current_user;
    //check Task status
    $id = $bean->id;
    $query = "SELECT status FROM tasks WHERE parent_id = '$id' AND deleted = '0'";
    $result = $db->query($query,true);
    $rows = $db->fetchByAssoc($result);
    $check = 0;
    foreach ($row as $rows) {
    if ($row['status'] != 'Completed') {
    $check = 1;
    $GLOBALS['log']->test('check: '.$id);
    break;
    }
    }
    if ($check = 1) {
    throw new SugarApiExceptionError('Unable to Closed. Please set Task to Completed');
    $GLOBALS['log']->test('check: '.$check);
    }
    }
    }

    It dose not work with your code throw new SugarApiExceptionError('Unable to Closed. Please set Task to Completed');

    Please help me. Thanks