I want to add an edit function if user decides to change the field value but i cant seem to find the right way to do this. Ive tried searching through google but it doesn't give any answer related for this problem.
code here:
<?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'])){
if (!empty($bean->field_name)) {
//if ticket status is closed then it displays an error message
$module = BeanFactory::getBean("CUSTOM MODULE", $bean->field_name);
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();
}
}
//edit function
} elseif ($_REQUEST['action'] == 'EditView') {
//code here
//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));
}
}
}