0

I am getting the following error when i try to update the item's name in the sharepoint document library. The item is of type document set and its default values is loaded using javascript. In the Item added event we are updating with the new changed item's name value. But in the item.update() code statement i am getting following error.

The File CZY14389 has been modified by domain\username on current date.

Please provide your commens on resolving this.

4 Answers 4

1

You cannot change the name of a sharepoint document like that. You need to "move it".

Item.Update();
Item.File.MoveTo(Item.ParentList.RootFolder.Url + "/" + newFileName, false);
Item.File.Item["FileRef"] = newFileName;
Item.File.Update();
0

before you update item name and call item.update(), can you try to refresh your item like this:

 item = item.ParentList.GetItemById(item.ID);
 item.name = "xyz";
 item.update();
0

this can sometimes happen in event handler. the problem is the updation process in the event handler is not as the same of the workflow. In event handler for updating you have to use the followitn steps. Dont use Item.Update() as in workflow.

Follow the steps:

• call and disable event firing before your code with : base.EventFiringEnabled = false;

•update your item by calling item.systemUpdate(false);

•enable event firing with : base.EventFiringEnabled = true;

0

Disable event firing and call your update code, dont forget to enable event firing.

     HandleEventFiring handleEventFiring = new HandleEventFiring();  
        handleEventFiring.DisableHandleEventFiring();     
     try  
            {  
                item.Update(); 
//if item.Update  doesnt work then use(For me item.update worked only on my local not on prod then i used the below)  
//item.SystemUpdate(false)
            }  
            finally  
            {  
                handleEventFiring.EnableHandleEventFiring();  
            }








 public class HandleEventFiring : SPItemEventReceiver  
    {  

        public void DisableHandleEventFiring()  
        {  
            //obsolete  
            //this.DisableEventFiring();  
            this.EventFiringEnabled = false;  
        }  

        public void EnableHandleEventFiring()  
        {  
            //obsotete  
            //this.EnableEventFiring();  
            this.EventFiringEnabled = true;  
        }  
    }  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.