如果用户决定更改字段值,我想添加一个编辑功能,但我似乎找不到正确的方法来做到这一点。我试过通过谷歌搜索,但它没有给出与这个问题相关的任何答案。
代码在这里:
<?php
class CloseTicket
{
public function do_CloseTicket($bean, $events, $args)
{
//checks if the ticket is already in use
if(!isset($bean->fetched_row['field_name_id'])){
if (!empty($bean->field_name)) {
//if ticket status is closed then it displays an error message
$module = BeanFactory::getBean("CUSTOM MODULE", $bean->field_name_id);
if ($module->status == 'Closed') {
SugarApplication::appendErrorMessage("Ticket is already used. Please use another Ticket.");
$params = array(
'module' => 'Module',
'action' => 'ListView',
'record' => $bean->id,
);
SugarApplication::redirect('index.php?' . http_build_query($params));
//else adds the ticket then closed it
} else {
$module->status = "Closed";
$module->save();
}
}
//if ticket is already taken then it display an error message
} else {
SugarApplication::appendErrorMessage("Ticket is already attached.");
$params = array(
'module' => 'module',
'action' => 'ListView',
'record' => $bean->id,
);
SugarApplication::redirect('index.php?' . http_build_query($params));
}
}
}