In my previous blog I have focused on how Standard Business Object e.g. Contact can be replicated from Service Cloud to Eloqua.
Now, in this blog focused will be, how Custom Object can be replicated from Service Cloud to Eloqua.
Usecase:
Currently, Service Cloud Adapter only support 3 business object event processing through adapter 1) Contact 2) Incident and 3) Organisation.
If you need to process the event for any other objects, other that what listed above then you need follow the path of Custom Object, Custom Event, associate Custom Event to Custom Object etc.
In this example use-case, I will be creating a Degree Custom object which will hold the value of Contact's degree information e.g. Degree Name, Degree Status, Email address etc and data will be replicated from Service Cloud to Eloqua whenever that degree object gets created.
Below are the high level steps needs to follow -
Eloqua - Create Custom Object
Login to Eloqua.Navigate to Audience >> Custom Object and Click on Create New Custom object as below
Give the name of the Custom object and the default linking field and click next
Add the new fields as required: E.g. Degree Status
Leave the group by class to default value, check summary page and finish the wizard
Service Cloud - Create Custom Object
Custom object can be created using Service Cloud Desktop agent only. Installing and accessing desktop agent I have already covered in my previous blog.
Once package gets created, add degree object
Create new field by clicking the Add New Fields on the header and save with appropriate data type and length
Once the fields are created, Click on Deploy and then immediately for it to get deployed and to be used in the integration flow.
Service Cloud - Create Custom Event Handler
So, far we have created Custom object and added some fields into it. In next step we have to add custom event handler because Service Cloud Adapter doesn’t support Custom object event trigger using standard event subscription process.
Hence, we need to use alternate approached offered by Service cloud which “Custom Process” is wherein we can design custom event handler and attach to Custom object. Custom event handler can invoke a PHP script which in-turn invoke OIC Integration URL using cURL method and pass data in JSON format.
We also need to associate Custom object to read/update/delete operation in order to invoke Custom event handler.
So, follow below steps to do that.
Click new to create new object event handler, give some value name e.g. SendCOtoICSREST, browse the php file e.g. SendCOtoICS.php which you have written to invoke OIC Integration, once you browse the file and open it, save it, Test button gets highlighted, click test button and state should show “Tested” in green color. If PHP has some error, you will see error. The PHP script will be visible in this screen read only format.
Note: PHP script was provided by Service Cloud Engineer or refer Service Cloud document how to prepare PHP script, make sure you modify OIC Integration URL, username and password inside PHP script.
Once event handlers get created, go back to Custom object what you have created and associate this event handler to various operation possible on that custom object. Refer below snap –
In above snap, custom event handler getting linked to Custom object create and update operation.
OIC - Create REST Adapter for Service Cloud Consumption
Since we need to expose OIC integration as REST API, we need to use REST Adapter as trigger point for Service Cloud to Invoke OIC Rest Integration API. So, create a REST Adapter which will be used to Invoke OIC Integration with basic authentication.
OIC - Reuse Eloqua Adapter connection
In previous blog, we have already created Eloqua connection, so use the same connection for Eloqua.
OIC - Create Integration
Now, both source and target connection ready, start building integration, select basic routing integration and drop Service Cloud REST connection on left hand side, wizard get open, specify all standard stuff e.g. endpoint name, endpoint resource relative URI, post method, tick on configure request payload option.
Note: I have selected basic routing just for quick implementation but that’s not the recommended integration pattern, better selecting apps orchestration one which will offer much better orchestration capabilities.
Specify custom object JSON payload
{ "Degree_Name":"MCA", "Degree_status":"Passed", "Email_address":"manish.ku.gupta@oracle.com","contact":"797864545" }
Similarly, drop Eloqua Connection on right hand side, wizard will get open, specify endpoint name of your choice, select “Degree CO” custom object, select the fields, link to email Contact.EmailAddress CDO this degree object as per given snap.
Next, perform mapping, it’s pretty straight forward mapping since both side we have same Custom Degree object.
Once, save your integration look like below –
Specify EmailAddress as tracking field and activate integration
Once Integration activated, get the OIC Integration URL e.g.
https://mgu-oic-dev-apacanzset01.integration.ocp.oraclecloud.com:443/ic/api/integration/v1/flows/rest/SYNCDEGR_SRVCLOUDREST_TO_ELOQUA/1.0/srvCloud/syncCustomObject
Once OIC Integration URLs gets generated, update PHP script with this URL, go back to Service Cloud Custom Event Handler, update php script, browse updated PHP script, , Save it, Test it and Deploy it.
Testing
In order to trigger this integration, Custom object needs to be created, for that you need a Custom Object UI. Talk to Service Cloud expert or documentation, how a Custom UI can be created in Service Cloud to show Degree Custom Object. Insert the new record using that UI, which eventually trigger the Integration using PHP cURL command and OIC will update Eloqua with Custom object records.
Track Instance in OIC-
Jump to OIC >> Integration >> Monitoring >> Tracking to see the latest instance of this event.Verify Custom Object Data in Eloqua Custom Object Screen
Navigate to Audience >> Custom Object >> Select Degree CO >> View Custom Object Record===========================================================================
Here is the PHP Script file content -
/*
* CPMObjectEventHandler: SendCOtoICS
* Package: Degree_CO
* Objects: Degree_CO$Degree
* Actions: Create, Update
* Version: 1.2
* Purpose: Trigger ICS integration for CO
*/
use \RightNow\Connect\v1_2 as RNCPHP;
use \RightNow\CPM\v1 as RNCPM;
/*-------------------------------------------------------------------------------------
The Actual Event Handler
-------------------------------------------------------------------------------------*/
class SendCOtoICS implements RNCPM\ObjectEventHandler{
public static function apply($run_mode, $action, $obj, $n_cycles)
{
if ($n_cycles !== 0) return;
$DegreeCO = RNCPHP\Degree_CO\Degree::fetch($obj->ID);
$Degree_Name = $DegreeCO->Degree_Name;
$Degree_status = $DegreeCO->Degree_status;
$Email_address = $DegreeCO->Email_address;
date_default_timezone_set('UTC');
$now = date("c");
$oneminlater = date("c", strtotime($now) + 60);
$now = substr($now, 0, -6).".100Z";
$oneminlater = substr($oneminlater, 0, -6).".100Z";
echo("
Now_date = $now \n");
Now_date = $now \n");
echo("
oneminlater = $oneminlater \n");
oneminlater = $oneminlater \n");
$message='
$url = "https://OICNZic-gse00014606.integration.ocp.oraclecloud.com:443/ic/ws/integration/v1/flows/rightnow/DEGREESVCTOELQ/1.0/";
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: ".strlen($message),
);
// echo("about to send request to $url");
//logMessage("REQUEST:");
echo ("
REQUEST-MESSAGE placed = $message");
REQUEST-MESSAGE placed = $message");
load_curl();
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 20);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLINFO_HEADER_OUT, true);
$response = curl_exec($soap_do); //invoke the external endpoint using the attributes gathered above e.g. messsae, url, header,
echo("
RESPONSE RECEIVED = $response");
RESPONSE RECEIVED = $response");
//$obj->CustomFields->c->Siebel->XMLResponse = $response;
/*$info = curl_getinfo($soap_do);
echo "
CURL - INFO:".'
';
CURL - INFO:".'
';
foreach ($info as $key => $value){
echo " \t $key: $value
\n";
\n";
}*/
curl_close($soap_do);
}
}
/*-------------------------------------------------------------------------------------
The Test Harness
-------------------------------------------------------------------------------------*/
class SendCOtoICS_TestHarness implements RNCPM\ObjectEventHandler_TestHarness{
static $myobject = null;
public static function setup()
{
$DegreeCO = new RNCPHP\Degree_CO\Degree();
$DegreeCO->Degree_Name = "Test Degree Name";
$DegreeCO->Degree_status = "Test Status";
$DegreeCO->Email_address = "test@test.com.invalid";
$DegreeCO->save();
self::$myobject = $DegreeCO->ID;
}
public static function fetchObject($action, $object_type )
{
$degree = $object_type::fetch(self::$myobject);
return array($degree);
}
public static function validate($action, $object )
{
echo "Test Passed!!";
return true;
}
public static function cleanup()
{
if (self::$myobject)
{
$DegreeCO = RNCPHP\Degree_CO\Degree::fetch(self::$myobject);
$DegreeCO->destroy();
self::$myobject = null;
}
}
}
=====================================================================
I hope this blog help you to integrate Service Cloud to Eloqua using Custom Object Event Trigger mechanism. I will be writing another one where you can witness Bulk data import from Service Cloud to Eloqua. So stay tuned :)
No comments:
Post a Comment