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

Picture08

Once package gets created, add degree object

Picture09

Picture10

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

Picture11

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.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.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.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: 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(“<br>Now_date = $now \n”);
    echo(“<br>oneminlater = $oneminlater \n”);
    $message='<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:typ=”http://xmlns.oracle.com/pcbpel/cloud/connector/rightnow/types&#8221; xmlns:v1=”urn:base.ws.rightnow.com/v1_4″>
     <soapenv:Header>
         <wsu:Timestamp wsu:Id=”TS-4423A630267057D261153536198950911″>
          <wsu:Created>2018-08-27T09:26:29.509Z</wsu:Created>
          <wsu:Expires>2018-08-27T09:27:29.509Z</wsu:Expires>
         </wsu:Timestamp>
         <wsse:UsernameToken wsu:Id=”UsernameToken-4423A630267057D261153536198060510″>
          <wsse:Username>cloud.admin</wsse:Username>
          <wsu:Created>2018-08-27T09:26:20.605Z</wsu:Created>
         </wsse:UsernameToken>
       </wsse:Security>
     </soapenv:Header>
     <soapenv:Body>
       <ns0:process xmlns:ns1=”urn:base.ws.rightnow.com/v1_4″ xmlns:ns2=”Degree_CO” xmlns:ns0=”http://xmlns.oracle.com/cloud/adapter/rightnow/degree_SVC_REQUEST/types”&gt;
       <ns0:Degree_CO.Degree>
         <ns2:Contact>
          <ns1:ID id=”‘.$obj->ID.'”/>
         </ns2:Contact>
         <ns2:Degree_Name>’.$Degree_Name.'</ns2:Degree_Name>
         <ns2:Degree_status>’.$Degree_status.'</ns2:Degree_status>
         <ns2:Email_address>’.$Email_address.'</ns2:Email_address>
       </ns0:Degree_CO.Degree>
    </ns0:process>
     </soapenv:Body>
    </soapenv:Envelope>’;
    $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 (“<br> 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(“<br>RESPONSE RECEIVED = $response”);
    //$obj->CustomFields->c->Siebel->XMLResponse = $response;
    /*$info = curl_getinfo($soap_do);
    echo “<br>CURL – INFO:”.'<br>’;
    foreach ($info as $key => $value){
      echo “&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\t $key: $value <br />\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 🙂

Author: Manish Kumar Gupta

I am currently designated as Principal Presales Consultant in Oracle, Sydney, Australia. Having 14 + years professional experience. Currently Looking after presales activites 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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s