none
Item can not be saved because some other user or window has changed it RRS feed

  • Question

  • Hi,

    I encounter a strange behavior. I have added a ItemChange-Eventhandler to an Appointment-Folder.If an Appointment changes, a linked TaskItem has to be updated.

            void Calendar_ItemChange(object Item)
            {
                // if there is already a linked BO try to update it
                Outlook.AppointmentItem dateItem = (Outlook.AppointmentItem)Item;
    
                Outlook.UserProperty boEntryID = dateItem.UserProperties["linkedBOId"];
                Outlook.UserProperty boStoreID = dateItem.UserProperties["linkedBOStore"];
    
                if ((boEntryID != null) && (boStoreID != null))
                {
                    string boID = (string)boEntryID.Value;
                    string boStore = (string)boStoreID.Value;
    
                    Outlook.TaskItem linkedBo = (Outlook.TaskItem)Application.Session.GetItemFromID(boID, boStore);
                    if (linkedBo != null)
                    {
                        if (linkedBo.Subject == null)
                        {
                            linkedBo.Subject = dateItem.Subject;
                        }
                        else
                        {
                            if (dateItem.Subject != linkedBo.Subject)
                            {
                                dateItem.Subject = linkedBo.Subject;
                                dateItem.Save();
                            }
                        }
                        Outlook.UserProperty ShowStart = linkedBo.UserProperties.Find("ShowStart", true);
    
                        ShowStart.Value = dateItem.Start;
                        linkedBo.DueDate = dateItem.Start;
    
                        //When the boItem is alreadyopen in an inspector isOpenInInspector exists
                        Outlook.UserProperty isOpenInInspector = linkedBo.UserProperties.Find("boIsOpenInInspector", true);
                        if (isOpenInInspector == null) // boItem is not opened
                        {
                            linkedBo.Save();
                        }
                        else
                        {
                            Marshal.ReleaseComObject(isOpenInInspector);
                        }
    
                        if (ShowStart != null) Marshal.ReleaseComObject(ShowStart);
                        if (boEntryID != null) Marshal.ReleaseComObject(boEntryID);
                        if (boStoreID != null) Marshal.ReleaseComObject(boStoreID);
    
                        if (linkedBo != null) Marshal.ReleaseComObject(linkedBo);
                        if (dateItem != null) Marshal.ReleaseComObject(dateItem);
    
    
    
                        linkedBo = null;
    
                    }
                }
    
            }

    If I move the Appoinment several times with the Mouse

     to change it, occasionally I get the error message that I can't change the item because someone else has changed it (this is a single user enviroment Outlook 2007 with .pst).

    Also sometimes when I Close Outlook after moving the Appointment I get twice or 4 times a Dialog asking me, if I want so save changes. Is there a way to find out, which items are not saved? Actually they should all be saved.

    I was guessing, that perhaps I don't free some COM-Object and added Marshal.ReleaseComObject. It got better, but still sometimes I get this errors.


    Monday, October 28, 2013 4:33 PM

All replies

  • Hi,

    >>If I move the Appoinment several times with the Mouse to change it, occasionally I get the error message that I can't change the item because someone else has changed it (this is a single user enviroment Outlook 2007 with .pst). <<

    As you said, you move the Appointment several times to trigger the ItemsEvents_Event.ItemChange event “Calendar_ItemChange”. However, the callback of event of ItemsEvents_Event is asynchronous. Which means it is possible for multiple threads to update the same task item at the same time. I think that’s why you will get error message “can't change the item because someone else has changed it” occasionally. By the way, Office Object Model is not thread-safe and I suggest you to use lock statement to avoid this issue.

    >>Also sometimes when I Close Outlook after moving the Appointment I get twice or 4 times a Dialog asking me, if I want so save changes.<<


    From the code you provided, I find that you edit the Item “linkedBo” if the Subject of the “linkedBo" is null, but you will save it only when the UserProperty “isOpenInInspector” is null. Could you add a log to check that every change of “linkedBo” would be saved? Because of the  message of dialog box, it seems you have several unsaved changes.

    if (isOpenInInspector == null) // boItem is not opened
    {
        linkedBo.Save();
    }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 29, 2013 9:33 AM
    Moderator
  • Thanks for your help.

    I added the lock, but finally I found out what was the main problem.I did not think of the I have the Hotmail-Connector installed.

    It turned out that it saves my Appointments while Synchronizing. Perhaps it stores some Sync-Information in it.

    That was the reason for the message "Could not Save".

    When I switched Outlook to work offline everything was fine. But when online I get the effect again. Also when online it can happen when closing Outlook that it asks me if I wan't so save some changes and need pretty long to close down.

    I have no idea what coudl be the reason for this.

    Tuesday, October 29, 2013 12:28 PM