Oracle Service Cloud RightnowCX Custom Controller: Lookup Contact, Create Incident
<?php
namespace Custom\Controllers;
/************* Agent Authentication ***************/
require_once( get_cfg_var("doc_root")."/ConnectPHP/Connect_init.php" );
initConnectAPI();
use RightNow\Connect\v1_2 as RNCPHP;
class GSChatIncident extends \RightNow\Controllers\Base
{
function __construct()
{
parent::__construct();
}
public function createContactIncident() {
try{
\RightNow\Libraries\AbuseDetection::check();
//$incident->SiteInterface = new RNCPHP\NamedIDLabel();
//$incident->SiteInterface->ID = 111;
$email = $_POST['email'];
$cID = (int)$_POST['countryID'];
$languageID = (int)$_POST['langID'];
$CI = &get_instance();
$contactmodelobj=$CI->load->model('standard/Contact_model');
$found = $this->Contact_model->lookupContactByEmail($email, null, null)->result;
if($found != null && is_int($found) && $found != false){
$creatingContact = $found;
} else {
$creatingContact = 1;
}
$incident = new RNCPHP\Incident();
$incident->Subject = "Chat cancelled";
$incident->CustomFields->c->system_source->ID = 2156;
$incident->CustomFields->c->country = new RNCPHP\NamedIDLabel();
$incident->CustomFields->c->country = $cID;
$incident->Language = $languageID;
$incident->PrimaryContact = RNCPHP\Contact::fetch($creatingContact); //Required field to create an incident through connect PHP
$incident->save(RNCPHP\RNObject::SuppressAll);
}
catch (Exception $err ){
echo $err->getMessage();
}
}
}
?>
This entry was posted on Tuesday, August 30th, 2016 at 12:17 pm and is filed under Codeigniter, Oracle RightNow CX Technologies, PHP. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.