$ 0 0 Topic by JJContentPlease see image for the error and the code block for the code - any reason for this?Code Block<?php /** * CPMObjectEventHandler: MinimalIncidentHandler * Package: RN * Objects: Incident * Actions: Create, Update * Version: 1.2 * Purpose: Minimal CPM handler for incident create and update. */ use \RightNow\Connect\v1_2 as RNCPHP; use \RightNow\CPM\v1 as RNCPM; /** * Handler class for CPM */ class MinimalIncidentHandler implements RNCPM\ObjectEventHandler { /** * Apply CPM logic to object. * @param int $runMode * @param int $action * @param object $incident * @param int $cycles */ public static function apply($runMode, $action, $incident, $cycle) { if ($cycle !== 0) return; if (RNCPM\ActionUpdate == $action) { try{ $incident->CustomFields->CTU->CTC = 1264; $incident->save(); } catch (Exception $err ){ echo $err->getMessage(); } } elseif (RNCPM\ActionCreate == $action) { try{ $incident->CustomFields->CTU->CTC = 1265; $incident->save(); } catch (Exception $err ){ echo $err->getMessage(); } } } } /** * CPM test harness */ class MinimalIncidentHandler_TestHarness implements RNCPM\ObjectEventHandler_TestHarness { static $incidentOneId = null, $incidentTwoId = null; /** * Set up test cases. */ public static function setup() { // First test $incidentOne = new RNCPHP\Incident; $incidentOne->CustomFields->CTU->CTC = 1264; $cont = RNCPHP\Contact::fetch(52604); $incidentOne->PrimaryContact = $cont; $incidentOne->save(); self::$incidentOneId = $incidentOne->ID; // Second test $incidentTwo = new RNCPHP\Incident; $incidentTwo->CustomFields->CTU->CTC = 1265; $cont = RNCPHP\Contact::fetch(52604); $incidentTwo->PrimaryContact = $cont; $incidentTwo->save(); self::$incidentTwoId = $incidentTwo->ID; } /** * Return the object that we want to test with. You could also return * an array of objects to test more than one variation of an object. * @param int $action * @param class $object_type * @return object | array */ public static function fetchObject($action, $object_type) { $incidentOne = $object_type::fetch(self::$incidentOneId); $incidentTwo = $object_type::fetch(self::$incidentTwoId); return array($incidentOne, $incidentTwo); } /** * Validate test cases * @param int $action * @param object $incident * @return bool */ public static function validate($action, $incident) { if (RNCPM\ActionUpdate == $action) { if (assert($incident->CustomFields->CTU->CTC == 1264)) { echo "Update test passed\n"; return true; } else { echo "Update test FAILED\n"; } } elseif (RNCPM\ActionCreate == $action) { if (assert($incident->CustomFields->CTU->CTC== 1265)) { echo "Create test passed\n"; return true; } else { echo "Create test FAILED\n"; } } else { echo "Invalid action"; } return false; } /** * Destroy every object created by this test. Not necessary since in * test mode and nothing is committed, but good practice if only to * document the side effects of this test. */ public static function cleanup() { if (self::$incidentOneId) { $incidentOne = RNCPHP\Incident::fetch(self::$incidentOneId); $incidentOne->destroy(); self::$incidentOneId = null; } if (self::$incidentTwoId) { $incidentTwo = RNCPHP\Incident::fetch(self::$incidentTwoId); $incidentTwo->destroy(); self::$incidentTwoId = null; } } } ?>