Comments

  • 1-1 of 1
  • Vanessa Abelardo Viana Beserra

    Hi,

    No error message appears. And I can set the other fields of this object, I just can't set this date. Below is the complete code:

    <?php
     
    /**
     * CPMObjectEventHandler:CPM_LOG_LUGGO
     * Package: OracleServiceCloud
     * Objects: Incident
     * Actions: Create, Update
     * Version: 1.3
     */
     
    use RightNow\Connect\v1_3 as RNCPHP;
    use \RightNow\CPM\v1 as RNCPM;
     
    function createLogCPM($error, $cpm_name)
    {
        try
    {  
            $log_cpm = new RNCPHP\CO\LOG_LUGGO();
            $log_cpm->Error = $error;
            $log_cpm->CPM_NAME = $cpm_name;
            $log_cpm->save(RNCPHP\RNObject::SuppressAll);
        }
    catch (RNCPHP\ConnectAPIError $err)
    {
    CPM_LOG_LUGGO::addLog("Catch createLogCPM APIError ***: ".$err->getMessage(), '***');
    CPM_LOG_LUGGO::addLog("Catch createLogCPM APIError: ".$err->getMessage(), $obj->ID);
     
    }
    catch(Exception $err) 
    {
    CPM_LOG_LUGGO::addLog("Catch createLogCPM ***: ".$err->getMessage(), '***');
    CPM_LOG_LUGGO::addLog("Catch createLogCPM: ".$err->getMessage(), $obj->ID);
     
    }
        return;
    }
     
     
     require_once(get_cfg_var('doc_root').'/include/config/config.phph');
     
     $GLOBALS['log'] = true;
     
     class CPM_LOG_LUGGO implements RNCPM\ObjectEventHandler
    {
     
        public static function apply( $run_mode, $action, $obj, $n_cycles )
        {
     
     
        try 
    {
     
    echo "data_Criacao_teste".$obj->CreatedTime;
     
    if(isset($obj->prev->Disposition->ID))
    $sol_ant = $obj->prev->Disposition->ID;
    else
    $sol_ant = 0;
     
    echo "sol_ant".$sol_ant."\n";
     
     
    if(isset($obj->Disposition->ID))
    $sol_atual = $obj->Disposition->ID;
    else
    $sol_atual = 0;
     
     
     
     
    if(isset($obj->prev->Category->ID))
    $category_ant = $obj->prev->Category->ID;
    else
    $category_ant = 0;
     
    // Aqui eu pego a categoria atual
     
    if(isset($obj->Category->ID))
    $category_atual = $obj->Category->ID;
    else
    $category_atual = 0;
     
     
     
    if($sol_atual != $sol_ant || $category_atual!=$category_ant)
     
    {
     
    $log_cpm_luggo = new RNCPHP\CO\LOG_LUGGO();
     
    $log_cpm_luggo->ID_INCIDENTE = $obj->ID;
     
     
    if(isset($obj->Disposition->ID))
    $log_cpm_luggo->SOLUCAO = RNCPHP\ServiceDisposition::fetch($obj->Disposition->ID);
     
    if(isset($obj->Category->ID))
    $log_cpm_luggo->CATEGORIA = RNCPHP\ServiceCategory::fetch($obj->Category->ID);
     
    $log_cpm_luggo->STATUS =$obj->StatusWithType->Status->LookupName;
     
    $log_cpm_luggo->DATA_FINAL=time();
     
    echo "dataaaa".$obj->DATA_FINAL;
     
    $log_cpm_luggo->save(RNCPHP\RNObject::SuppressAll);
    $obj->save(RNCPHP\RNObject::SuppressAll);
    }
     
     
    }
     
     
    catch (Exception $e) {
        echo 'Exceção capturada: ',  $e->getMessage(), "\n";
    }
     
     
     
    return;
    }
     
     
     
    }
     
     
     
    Thanks!