I have created task using Active Collab API also working with close task and reopen task using API. Now if I create or close or reopen task then want to notify user but I don’t know how to do this using Active Collab API.
Below is my code for create task, close task and reopen task.
/* create task using API */
try { $res = API::call('projects/60/tasks/add', null, array( 'task[name]' => $_POST['name'], 'task[body]' => $_POST['message'], 'task[priority]' => $priority, 'task[due_on]' => $date, 'task[assignee_id]' => 21, )); $GLOBALS['$mytask'] = $res['task_id']; $GLOBALS['$myValue'] = $res['permalink']; echo $GLOBALS['$myValue']."+="; echo $GLOBALS['$mytask']; //echo 'Ticket Created Successfully.'; } catch(AppException $e) { print $e->getMessage() . '<br><br>'; // var_dump($e->getServerResponse()); (need more info?) }
/*close task using API */
try { $res = API::call('projects/60/tasks/200/complete', null, array( 'submitted' => 'submitted', )); echo 'Ticket Updated Successfully.'; } catch(AppException $e) { print $e->getMessage() . '<br><br>'; }
/* Reopen task using API*/
try { $res = API::call('projects/60/tasks/200/reopen', null, array( 'task[body]' => $_POST['message'], 'submitted' => 'submitted', )); echo 'Ticket Updated Successfully.'; } catch(AppException $e) { print $e->getMessage() . '<br><br>'; }
What I need is to notify user when create or close or reopen task. For that what I need to change or add in above code?
And I also want to send mail to user who is responsible for this task (assign user).
Advertisement
Answer
Active Collab 4 has its own logic when sending emails. When you create a task, all assignees and subscribers will receive a notification. When you complete or reopen a task, system will also notify all subscribers. Note that person who performs the action is not notified (it’s redundant to notify you about something that you did).
That being said, I feel that you should and notifications to your PHP code, instead of relying on Active Collab to send notifications for you. That way you control the behavior, even when Active Collab changes (for example, version 5 does not notify subscribers that tasks are completed or reopened, you need to leave a comment to do that).