简体   繁体   中英

Trying to update Contact record but I get Permission to perform the operation is denied for id

I can search for an existing Contact and if none are found create a new one without a problem.

But if I do find a contact I want to make a change to the Contact Type field since they have just placed an order and should now be a Customer.

But when I do I get "Permission to perform the operation is denied for id". The code is very similar to the create and query and I have my session_name set and am referencing the right Id but not working for some reason.

$vtiger_id = $existingResult['result'][0]['id'];
// Update vTiger Contact Type
$updateData = array(
    'id' => $vtiger_id,
    'contacttype' => 'Customer',
    'assigned_user_id'  => $_SESSION['vtiger']['userId'],
);
$curl = curl_init($service_url);
$updateData = json_encode($updateData);
$curl_post_data = array(
    'operation' => 'update',
    'sessionName' => $_SESSION['vtiger']['sessionName'],
    'element' => $updateData,
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
// Send the request & save response to $resp
$resp = curl_exec($curl);
$result = json_decode($resp, true);
// Close request to clear up some resources
curl_close($curl);

OK.. so the issue was that the Last Name field was still required. I find that odd as the id should always be the true requirement for the update, since it should be unique and regardless of last name (since people share last names..) it should work with just that.

So by editing my script to include the Last Name it worked fine.

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