General Technical Discussions for Service

Get Involved. Join the Conversation.

Comments

  • Varun Chandran

    Hi Fabio,

    You can use Process Designer with which you can create event handlers [Custom Process Model written in PHP]. Using event handlers, you can fetch the contact object on its create, update and delete operations. You can try integrate it with your system while any of the operation is happening, through cURL/SOAP (limitations are there). You will have to work on it a little hard but you can do it.

    Hope if carves a way through.. 

    Best

    Varun

  • Andrew Rowse

    I think you are on the wrong Oracle product forum. This one is specific to the RightNow CX product.

    Maybe try this forum: https://community.oracle.com/community/developer/english/oracle_database/general_questions

  • Bishnu Paudel

    What a shame! my handler was not bound to the custom object at all. Sorry I wasted your time.

     

  • Bishnu Paudel

    Hi Varun,

    The apply function is wrapped inside the class in my code. I have other functions as well so I missed the closing "}" for class when I copied the apply function.

    Thanks,

  • Ross Crockett

    Hey Shreyas.

    I am using the cloud version, not on-premise. I am attaching the current test file, would someone with NuSOAP also in their env be able to test it out and see if they get the same issue?

    You will have to change the interface on line 37 but everything else should work. I've temporarily changed the webservice being called to a open web service which does currency conversion as a proof of concept.

    If you see more output after "Instantiating client" then you're doing better than me.

    Cheers,

    Ross

  • Bastiaan van der Kooij

    Ok continuing with my monologue; I have fixed the issue. Apparently during a multi update (and only multi), the only available fields in the object are the ones that are edited during this update together with the main ID. All other fields are not set, so I needed to fetch the object in the custom process when it was updated to work with the fields I needed. 

    No I am fetching the object for each update, like;

            if (RNCPM\ActionUpdate == $action)
            {
                $order = RNCPHP\Orders\OrderHeader::fetch($order->ID);
            }
     
  • Bastiaan van der Kooij

    I also tried to upload orders using the Data Import Wizard, to trigger the Custom process. Enabled the checkboxes for Execute External Events and made sure there was a field that was updated. But no luck, the CPM is simply not triggered....

    Creating new orders using the Data Import Wizard does work correctly, so it is only limited to batch updates that are not triggering the CPM.

  • Varun Chandran

    Wrap the apply function inside class StudyPlanRequestUpdate and try once.

    //class StudyPlanRequestUpdate starts here
    class StudyPlanRequestUpdate
            implements RNCPM\ObjectEventHandler
    {
        public static function apply( $run_mode, $action, $obj, $n_cycles )
        { 
    $subject="test subject";
            $inc = RNCPHP\Incident::fetch($obj->incident_id->ID); 
    var_dump($inc->Subject);
            $inc->Subject=$subject;
    var_dump($inc->Subject);
            $inc->save(); 
     
    return ;
    }
    }
    //class StudyPlanRequestUpdate ends here
     
    //class StudyPlanRequestUpdate_TestHarness starts here
    class StudyPlanRequestUpdate_TestHarness
            implements RNCPM\ObjectEventHandler_TestHarness
    {
    /*Code block*/
    }

     

  • Bishnu Paudel

    I think fetching of incident object is not necessary because $obj->incident_id already refers to an incident object. But this didn't help at all.

  • Bishnu Paudel

    Thank you for you inputs Varun. I appreciate that. 

    I have already tried this and it's not working which is driving me crazy. To avoid the confusion, I only have one STudyPlanReuest custom object record and I am using the same for testing and updating. The results of var_dump are as expected.

    Here is my code :

    <?
    /*
     * CPMObjectEventHandler: StudyPlanRequestUpdate
     * Package: CO
     * Objects: CO\StudyPlanRequest
     * Actions: Update
     * Version: 1.2
     */
     
     //Purpose of the script: Automatically create a new incident of type 'study plan' and bind it with newly created StudyPlanRequest record.
     
    // This object procedure binds to v1_1 of the Connect PHP API
    use \RightNow\Connect\v1_2 as RNCPHP;
    // This object procedure binds to the v1 interface of the process
    // designer
    use \RightNow\CPM\v1 as RNCPM;
    /**
     * An Object Event Handler must provide two classes:
     *   - One with the same name as the CPMObjectEventHandler tag
     *     above that implements the ObjectEventHandler interface.
     *   - And one of the same name with a "_TestHarness" suffix
     *     that implements the ObjectEventHandler_TestHarness interface.
     *
     * Each method must have an implementation.
     */
    class StudyPlanRequestUpdate
            implements RNCPM\ObjectEventHandler
    {
        public static function apply( $run_mode, $action, $obj, $n_cycles )
        { 
    $subject="test subject";
            $inc = RNCPHP\Incident::fetch($obj->incident_id->ID); 
    var_dump($inc->Subject);
            $inc->Subject=$subject;
    var_dump($inc->Subject);
            $inc->save(); 
     
    return ;
    }
     
     class StudyPlanRequestUpdate_TestHarness
            implements RNCPM\ObjectEventHandler_TestHarness
    {
        static $org_invented = NULL;
        public static function setup()
        {
      $studyplanform_id="184";
    $studyplanform = RNCPHP\CO\StudyPlanRequest::fetch($studyplanform_id);
           static::$org_invented = $studyplanform;
            return;
        }
        public static function
        fetchObject( $action, $object_type ){
            // Return the object that we
            // want to test with.
            // You could also return an array of objects
            // to test more than one variation of an object.
            return(static::$org_invented);
        }
        public static function
        validate( $action, $object )
        {
            // Add one note.
            return(true);
        }
        public static function cleanup()
        {
            // Destroy every object invented
            // by this test.
            // Not necessary since in test
            // mode and nothing is committed,
            // but good practice if only to
            // document the side effects of
            // this test.
            static::$org_invented->destroy().
            static::$org_invented = NULL;
            return;
        }
    }

     

  • Varun Chandran

    If you have to change incident subject, you will have to access the incident object for that. You will have to follow the same procedure, in place of 

    $inc = RNCPHP\Incident::fetch($obj->ID);

    use  

    $inc = RNCPHP\Incident::fetch(<incident_id from custom_object>);  the rest is the same.    

     

     

  • Bishnu Paudel

    Yes ! Exactly. :)

  • Varun Chandran

    I missed that part actually.. :)

    So you have to change the subject of the incident which is related to the custom object on its update. Correct me if i am wrong.

  • Bishnu Paudel

    Hi Varun,

    Sorry for the confusion again. if you look at my original question, I have mentioned that I am writing custom process for 'update' event of a custom object which will always be related to only one incident object.

    Thanks,

  • Varun Chandran

    Bishnu,

    I am not sure why you are using 

    $obj->incident_id->Subject instead of $obj->Subject as $obj will be the incident object.

    try 

    public static function apply( $run_mode, $action, $obj, $n_cycles )
        { 
         if($action==2){                   //update =2
            $subject="test subject";
            $inc = RNCPHP\Incident::fetch($obj->ID);       
            $inc->Subject=$subject;
            $inc->save(); 
          }         
    return ;
        }
     
    Best
     
    Varun