I am working on web services of vtigercrm, I want to create a document in the document module in vtigercrm 6.5 using web service, how I can do create a new document in document module in vtigercrm?
I create one PHP file, where I made a form for creating an organization in along with i also want to create document too. so that i set also file uploading input tag in that form, and i post all data to the url.php, where i setting the array and passing params to the
$params = array(
'notes_title'=>$accountname,
'filesize' => $filesize,
'filetype' => $filetype,
'filename'=>$filename,
'assigned_user_id'=>$assigned_user);
and encode them
$objectJson = Zend_JSON::encode($params);
set module name
$moduleName = 'Documents';
set params and operation
$params = array("sessionName"=>$sessionId, "operation"=>'create', "element"=>$objectJson, "elementType"=>$moduleName);
$httpc->post($endpointUrl.$urlArgs, $params, true); $response = $httpc->currentResponse();
but here when ever i print $response, i will get this error messege
[body] => {"success":false,"error":{"code":"DATABASE_QUERY_ERROR","message":"Database error while performing requested operation"}}
continue code :
$jsonResponse = Zend_JSON::decode($response['body']);
$savedObject = $jsonResponse['result'];
here i write this code for geting name and size and type of a file.
if($_FILES['fileToUpload']['name'] != ''){
$errCode=$_FILES['fileToUpload']['error'];
if($errCode == 0){
foreach($_FILES as $fileindex => $files)
{
if($files['name'] != '' && $files['size'] > 0){
$filename = $_FILES['fileToUpload']['name'];
$filename = from_html(preg_replace('/\s+/', '_', $filename));
$filetype = $_FILES['fileToUpload']['type'];
$filesize = (string)$_FILES['fileToUpload']['size'];
$filelocationtype = 'I';
$binFile = sanitizeUploadFileName($filename, $upload_badext);
$filename = ltrim(basename(" ".$binFile)); //allowed filename like UTF-8 characters
}
}
}
}
when ever i run the code into my vtigercrm i got the failed arror msg into my log
Query Failed:UPDATE vtiger_notes SET filename = ? ,filesize = ?, filetype = ? , filelocationtype = ? , filedownloadcount = ? WHERE notesid = ?::->[1048]Column 'filesize' cannot be null
i think the error shows Column 'filesize' cannot be null
But above in my code i already get the size of an file and i already passed into query. then why i got this error.
i tried so many times, any one can help me out from this.
Thank you In Advance, Waiting for positive reply.