Topic by Salvatore
Content
Hello,
I'm trying to update/delete a list of contacts obtained via a QueryObjects call, but I always get the following error messages:
CreatedTime may not be set due to visibility restrictions while performing the operation: destroy
While processing Contact->CreatedTime(dateTime)
CreatedTime may not be set due to visibility restrictions while performing the operation: update
While processing Contact->CreatedTime(dateTime)
It's not clear why the Destroy and BeginUpdate calls both fail, since the list of contacts is populated correctly (see the attached screenshot). Do you have any ideas/suggestions?
My main goal is to append a suffix to the contacts' login&e-mail fields.
Thanks and kind regards,
Salvatore
-------------------
publicvoid DeleteContacts(List<Contact> contacts) { //Create the DestroyProcessingOptionsDestroyProcessingOptions options = newDestroyProcessingOptions(); options.SuppressExternalEvents = false; options.SuppressRules = false; if (contacts != null) foreach (Contact c in contacts) { // Safety check - Not really needed, but we are deleting contacts!foreach (GenericField cf in c.CustomFields) { if (cf.name == "c$csat_imported") if ((bool)cf.DataValue.Items[0]) { RNObject[] objects = newRNObject[] { c }; ClientInfoHeader clientInfoHeader = newClientInfoHeader(); clientInfoHeader.AppID = "TEST"; //Invoke the Delete operation. This point is reached but the call fails _service.Destroy(clientInfoHeader, objects, options); MessageBox.Show(c.Login); // Debug only } } } } publicvoid BeginUpdateContacts(List<Contact> contacts) { //Create the update processiong optionsUpdateProcessingOptions options = newUpdateProcessingOptions(); options.SuppressExternalEvents = false; options.SuppressRules = false; foreach (Contact c in contacts) { // Already updated?if (!c.Login.Contains("-CSAT")) { c.Login += "-CSAT"; NamedID addressType = newNamedID(); ID primarymailID = newID(); primarymailID.id = 1; addressType.ID = primarymailID; addressType.ID.idSpecified = true; c.Emails[0].AddressType = addressType; c.Emails[0].Address += "-CSAT"; c.Emails[0].action = ActionEnum.update; c.Emails[0].actionSpecified = true; RNObject[] objects = newRNObject[] { c }; try { ClientInfoHeader clientInfoHeader = newClientInfoHeader(); clientInfoHeader.AppID = "TEST"; _service.BeginUpdate(clientInfoHeader, objects, options, newAsyncCallback(BeginUpdateContactsCallback), null); } catch (FaultException e) { // Handle FaultException without using the MessageBoxMessageBox.Show(e.Message); } catch (SecurityAccessDeniedException e) { MessageBox.Show(e.Message); } } } }
Image
Image may be NSFW.Clik here to view.
