/** * GetData function of the widget * @return null */ function getData() { // get srID if (!($srID = intval(URL::getParameter('sr_id')))) { $incidentID = URL::getParameter('i_id'); if (!($incidentID = intval(URL::getParameter('i_id')))) { echo $this->reportError('Invalid i_id'); return; } $incident = RNCPHP\Incident::fetch(intval($incidentID)); if (!is_null($incident)) { $srID = $incident->CustomFields->Accelerator->ebs_sr_id; } } // render data to javascript $this->data['js']['sr_id'] = $srID; $this->data['js']['ext_server_type'] = $this->extServerType; $this->data['js']['development_mode'] = IS_DEVELOPMENT; }
/** * PostIncidentCreateHook for Siebel handles two differenct cases based on if the sr_id is empty * 1. if sr_id is empty, the hook is for incident created through the 'Ask a New Question' page * 2. otherwise, the hoos is incident created based on a legacy SR * @param array &$hookData HookData */ function postIncidentCreateHook(array &$hookData) { $incidentID = $hookData['data']->ID; if (!($incident = RNCPHP\Incident::fetch(intval($incidentID)))) { $this->log->error("Unable to get Incident#{$incidentID}", __METHOD__, array(null, $this->contact)); } else { $this->log->debug("Incident #{$incidentID} has been created in CP", __METHOD__, array($incident, $this->contact)); } // check if the incident has been associated with a SR if ($srID = $incident->CustomFields->Accelerator->siebel_sr_id) { $this->createIncidentToLinkWithSR($srID, $incident); } else { $this->createSRFromCPToLinkWithIncident($incident); } }
/** * Add additional fields which are unable to be added by the standard input widget to the Incident * @param RNCPHP\Incident $incident RightNow Incident object */ private function addAdditionalFieldsToIncident(RNCPHP\Incident $incident) { // set the 'ebs_sr_owner_id' $incident->CustomFields->Accelerator->ebs_sr_owner_id = $this->CI->model('custom/ExtIntegrationConfigVerb')->getEbsDefaultSROwnerID(); $incident->save(RNCPHP\RNObject::SuppressAll); }
/** * Compose the Serial Number and Product validation result. * Operations contains: * 1. log the validation result * 2. save the result in the custom attribute 'cp_ebs_product_validation' if needed * 3. return the result containing isValid, meesage and item object * @param boolean $isValid Indicate if the validation is correct * @param string $message Validation result message * @param array $ebsItem Item of the provided Serial Number * @param RNCPHP\Incident $incident Related incident object * @param boolean $ifNeedToSaveInIncident Indicate if the checking result need to be saved in the incident * @param boolean $isError If the response is an error. for example, "Serial Number not found" is invalid, but not an error * @return array Validation result contains status, response, and item */ private function composeSerialNumberValidationResult($isValid, $message, array $ebsItem = null, RNCPHP\Incident $incident = null, $ifNeedToSaveInIncident = false, $isError = false) { if ($isError) { $this->log->error("Serial Number validation :: {$message}", __METHOD__, array($incident, $this->contact)); } else { if (!$isError && !$isValid) { $this->log->notice("Serial Number validation :: {$message}", __METHOD__, array($incident, $this->contact)); } else { $this->log->debug("Serial Number validation :: {$message}", __METHOD__, array($incident, $this->contact)); } } // save the validation result to incident if needed if ($incident !== null && $ifNeedToSaveInIncident === true) { $incident->CustomFields->Accelerator->cp_ebs_product_validation = $message; $incident->save(RNCPHP\RNObject::SuppressAll); } $result = (object) array('isValid' => $isValid, 'message' => $message, 'ebsItem' => $ebsItem, 'isError' => $isError); return $this->getResponseObject($result); }