Advertisement
carlfredrikhero

Event based task Creation for Podiohelp.com

Sep 18th, 2012
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. /* CODE BLOCK 1 */
  2. switch ($_POST['type']) {
  3.       case 'item.create':
  4.         // Do something. item_id is available in $_POST['item_id']
  5.         $item = $api->item->getBasic($_POST['item_id']);
  6.         $created_via = strtolower( $item['initial_revision']['created_via']['name'] );
  7.  
  8.         //is it created via webform or mail?
  9.         if (in_array($created_via, array('webform','mail'))){
  10.             $task = array(
  11.                 'text' => 'Task title goes here',
  12.                 'description' => 'Description of task goes here',
  13.                 'responsible' => USER_ID, // the assigned user
  14.             );
  15.  
  16.             $result = $api->task->createWithReference('item',$_POST['item_id'],$task);
  17.             $task_id = $result['task_id'];
  18.         }
  19.     break;
  20.    
  21.     /* CODE BLOCK 2 */
  22.     case 'item.update':
  23.         // get the current Value of the Candidate Stage field
  24.         $status = $api->item->getFieldValue($_POST['item_id'],APP_FIELD_ID); // field id set as a constant
  25.  
  26.         // read first value of "applicant-stage", if "Rejected", create task
  27.         if ($status[0]['value'] == 'Rejected'){
  28.            
  29.             $task = array(
  30.                 'text' => 'Task title goes here',
  31.                 'description' => 'Description of task goes here',
  32.                 'responsible' => USER_ID, // the assigned user
  33.             );
  34.            
  35.             $result = $api->task->createWithReference('item',$_POST['item_id'],$task);
  36.             $task_id = $result['task_id'];
  37.         }
  38.     break;
  39.  
  40.     /* END CODE BLOCK 2 */
  41. }
  42. /* END CODE BLOCK 1 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement