I have created an event receiver with ItemUpdated properties. I want to update some field if new document is uploaded. But whenever the any field is updated, ItemUpdated is fired. I want to check that my code is run only if new document is uploaded.

Is there any way that file is uploaded or properties updated ?

  • 3
    Then wouldn't you want to use ItemAdding or ItemAdded? – Eric Alexander Jun 19 '15 at 15:55
  • @EricAlexander no, i have already added a file to doc library. now when i again upload same file, it fires ItemUpdated. But how can i identify that its a file updated or field updated ? – user36977 Jun 19 '15 at 16:00
  • Your question wasn't clear in that case. There is no difference in field or file modification in this situation, both fire ItemUpdating. – Eric Alexander Jun 19 '15 at 16:39
  • @EricAlexander so how can i identify that file is modified ? is that possible to find out ? – user36977 Jun 20 '15 at 14:55
  • 2
    I don't know if in the Before and AfterProperties if you can tell if the overwrite check box was checked or tell if there is a file size difference, that would be my only guess – Eric Alexander Jun 20 '15 at 17:04

I got the solution as per @Eric Alexander comment. We can find the file size difference so we will identify that it is file updated or field update.

| improve this answer | |

Your Answer

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