Oracle Service Cloud to Eloqua Custom Object Replication using OIC

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 –

Pic01.png

Eloqua – Create Custom Object

Login to Eloqua.

Navigate to Audience >> Custom Object and Click on Create New Custom object as belowPicture2

Give the name of the Custom object and the default linking field and click next

Picture03

Add the new fields as required: E.g. Degree Status

Picture04

Picture06

Leave the group by class to default value, check summary page and finish the wizard

Pictureo5

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.

Login to Agent desktop. and navigate to the Navigation>>Database>>Object Designer >> New Package

Picture07-1.png

 

Picture08

Once package gets created, add degree object

Picture09-1.png

Picture10-1.png

 

Create new field by clicking the Add New Fields on the header and save with appropriate data type and length

Picture11-1.png

 

Once the fields are created, Click on Deploy Picture12and 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.

Navigate to Navigation >> Site Configuration >> Process Designer

Picture13-1.png

 

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.

I will include SendCOtoICS.php content at the end of the blog. 

Picture14-1.png

 

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 –

Picture15-1.png

 

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.

Picture16.png

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.

Picture17.png

Specify custom object JSON payload

{ “Degree_Name”:”MCA”, “Degree_status”:”Passed”, “Email_address”:”manish.ku.gupta@oracle.com”,”contact”:”797864545″ }

Picture18.png

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.

Picture19.png

Next, perform mapping, it’s pretty straight forward mapping since both side we have same Custom Degree object.

Picture20.png

Once, save your integration look like below –

Picture21.png

Specify EmailAddress as tracking field and activate integration

Picture22.png

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

Picture23.png

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.

Picture24

Track Instance in OIC-

Jump to OIC >> Integration >> Monitoring >> Tracking to see the latest instance of this event.

Picture25.png

Verify Custom Object Data in Eloqua Custom Object Screen

Navigate to Audience >> Custom Object >> Select Degree CO >> View Custom Object Record

Picture26

Picture27

===========================================================================

Here is the PHP Script file content –

<?
/*
* CPMObjectEventHandler: SendCOtoICSREST
* Package: Degree_CO
* Objects: Degree_CO$Degree
* Actions: Create, Update
* Version: 1.2
* Purpose: Trigger ICS integration for CO via REST Adapter
*/
use \RightNow\Connect\v1_2 as RNCPHP;
use \RightNow\CPM\v1 as RNCPM;
/*————————————————————————————-
The Actual Event Handler
————————————————————————————-*/
class SendCOtoICSREST 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 = $obj->Degree_Name;
    $Degree_status = $obj->Degree_status;
    $Email_address = $obj->Email_address;
    //—–cURL it!
    //Add to data body for json_encoding
    $CO_body = array(
     “Degree_Name” => $Degree_Name,
     “Degree_status” => $Degree_status,
     “Email_address” => $Email_address
    );
    //Send JSON data to test endpoint
    $json_body = json_encode($CO_body);
    //$domain = “http://requestbin.fullcontact.com/171cwvb1&#8221;; //Test RequestBin
    $auth_header = “Basic bWFuaXNoLmt1Lmd1cHRhQG9yYWNsZS5jb206TDBnMW5ebjB0ZWJvb2s=”; //For ICS only
    load_curl();
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     ‘Connection: Keep-Alive’,
     ‘Content-Type: application/json’,
     //’Accept: application/json’
     ‘Authorization:’.$auth_header //Generated using POSTMAN (ICS Credentials)
    ));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘POST’);
    curl_setopt($ch, CURLOPT_URL, $domain);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json_body);
    $result = curl_exec($ch);
    $errno = curl_errno($ch);
    curl_close($ch);
    if($errno) {
     $error_message = curl_strerror($errno);
     echo “cURL error ({$errno}):\n {$error_message}”;
     $all_loaded = FALSE;
    }else{
     $json_decode_result = json_decode($result);
     //var_dump($result);
     print_r($json_decode_result);
     //print_r($result);
     echo “Successful!”;
     $all_loaded = TRUE;
    }
    //—- end curl
  }
}
/*————————————————————————————-
The Test Harness
————————————————————————————-*/
class SendCOtoICSREST_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 🙂

Author: Manish Kumar Gupta

I am currently designated as Principal Presales Consultant in Oracle, Sydney, Australia. Having 20 + years professional experience. Currently Looking after Presales activities for iPaaS related Cloud Offering e.g. Oracle SOA Cloud Services (OSCS), Oracle Integration Cloud Service (OIC), MFT and Oracle API Platform etc. In past I have worked for many small to large companies. I have played various roles such as Integration Solution Architect / Integration Technical Architect / Integration Team Lead / Integration Specialist / SOA Infrastructure Admin / SOA Designer and SOA Developer in multiple companies. I have worked in various OFMW products such as Weblogic, OSB, BAM, SOA Suite, OWSM and Mediator etc. I have good hands-on experience in SOA Administration as well. In addition to that, have handful experience of SOA Architecture, Analysis, Design, Development, SIT Testing, Performance and Load Testing, Production and Post-Production Support for SOA projects.

2 thoughts on “Oracle Service Cloud to Eloqua Custom Object Replication using OIC”

Leave a comment