Does any one know how to properly format the update query in vtiger to update a record under the Leads module?
I have been following this: http://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html
and have been able to login, query, and do the challenge response, but I have been unable to get the update function to work and it could be because I am not sure how they want the query to look. This is the error I get when I send the query:
stdClass Object ( [success] => [error] => stdClass Object ( [code] => ACCESS_DENIED [message] => Permission to perform the operation is denied for id ) )
Current Test Code:
function updatesomeone(){
global $createduserleadnum;
global $url;
global $sessionID;
global $createduserid;
$customdata = array(
'firstname'=> 'TestAPILead2',//Update First name
'lastname'=> 'TestAPILeadLast2', //Updated Last name
'leadstatus'=> 'New',
'leadsource'=> 'Some Lead Source', //Not Real Lead source
'assigned_user_id'=> 'User-Assigned', //not real user
'cf_755'=> 'A Custom Field', // A Custom Field
'lead_no' => $createduserleadnum, Acquired from other function/stored value
);
$customdata = json_encode($customdata);
$field = array(
'operation' => 'update',
'sessionName'=> $sessionID,
'element' => $customdata
);
$fields_string;
foreach($field as $key=>$value) { global $fields_string;
$fields_string .= $key.'='.$value.'&'; }
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($field));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
$pringjson = json_decode($result);
print_r($pringjson);
}
Figured it out. It was related to the $fieldstring variable. For some reason it was not staying local to the function so it was including some other variables. just changed the fieldstring variable with a digit at the end. In the final code I will write a better script for url-ify'ing the variables. I also had to use the full id given. Either way it was resolved now and the code works as it should.