简体   繁体   中英

How to create an Activity with vTiger webservice?

I'm traying to create an activity using php.
I don't know why, the last var_dump is like "boolean false". This is my code.

$today=getdate();
$today=date("Y-m-d");

var_dump($today);

$modulet='Calendar';
$insertt= Array(
     'subject'=>'Call',
 'activitytype'=>'Task',
 'date_start'=>$today,
 'due_date'=>$today,
 'assigned_user_id'=>$vtiger->_userid ,
 'time_start'=>'09:00:00',
 'time_end'=>'17:00:00',
 'sendnotification'=>'0',
 'status'=>'Not Started',
 'priority'=>'High',
 'notime'=>'0',
 'visibility'=>'Private'
 );

var_dump($insertt);

$recordtask = $client->doCreate($modulet, $insertt);

var_dump($recordtask);

Check that the $vtiger->_userid is in the form 19x1 (module X user_id) and not just the integer value (eg 1 ). You could actually omit it if using the WSClient.php from the vtwsclib from vTiger.

This is the doCreate code.

    /**
 * Do Create Operation
 */
function doCreate($module, $valuemap) {
    // Perform re-login if required.
    $this->__checkLogin();

    // Assign record to logged in user if not specified
    if(!isset($valuemap['assigned_user_id'])) {
        $valuemap['assigned_user_id'] = $this->_userid;
    }

    $postdata = Array(
        'operation'   => 'create',
        'sessionName' => $this->_sessionid,
        'elementType' => $module,
        'element'     => $this->toJSONString($valuemap)
    );
    $resultdata = $this->_client->doPost($postdata, true);
    if($this->hasError($resultdata)) {
        return false;
    }       
    return $resultdata[result];
}

Maybe you want to var_dump the $resultdata instead of the result from the library, which is simply a boolean

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM