Using "Copy to" on document to copy it to the same library overwrites addin actions

%3CLINGO-SUB%20id%3D%22lingo-sub-1678844%22%20slang%3D%22en-US%22%3EUsing%20%22Copy%20to%22%20on%20document%20to%20copy%20it%20to%20the%20same%20library%20overwrites%20addin%20actions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1678844%22%20slang%3D%22en-US%22%3E%3CP%3EHi!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20someone%20can%20help%20me%20with%20this%20problem%20we%20have...%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20a%20custom%20addin%2C%20which%20generated%20a%20number%20for%20a%20document%20during%20the%20ItemAdding%20remote%20event%20receiver.%20When%20we%20add%20a%20document%2C%20it%20gets%20a%20number%2C%20let's%20say%20001.%20When%20we%20use%20%22Copy%20To%22%20to%20copy%20the%20document%20to%20another%20location%20(another%20library%20or%20site)%2C%20the%20copied%20document%20gets%20a%20new%20number%2C%20let's%20say%20002.%20This%20is%20as%20expected.%3CBR%20%2F%3E%3CBR%20%2F%3EHowever%2C%20when%20we%20copy%20the%20document%20this%20way%20to%20the%20current%20library%2C%20the%20new%20document%20gets%20the%20same%20number%20as%20the%20original%20document%2C%20which%20is%20001.%20It%20should%20have%20been%20003%20now...%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20the%20log%20file%20of%20our%20addin%20application%2C%20we%20can%20see%20that%20in%20every%20scenario%2C%20our%20addin%20software%20generates%20and%20assigns%20the%20newly%20generated%20number.%20However%2C%20the%20document%20has%20number%20001%20instead%20of%20003.%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20we've%20tried%3A%3C%2FP%3E%3CP%3E1.%20We%20have%20tried%20to%20copy%20the%20document%20to%20another%20folder%20within%20the%20same%20library.%20That%20has%20the%20same%20invalid%20result%20(same%20number%20as%20original).%3CBR%20%2F%3E2.%20We%20disabled%20the%20ItemAdding%20event%20receiver%20and%20enabled%20the%20ItemAdded%20event%20reveiver.%20In%20this%20case%2C%20the%20document%20that%20is%20copied%20to%20the%20same%20library%20as%20the%20original%2C%20gets%20a%20new%20number.%20So%2C%20this%20is%20good.%3C%2FP%3E%3CP%3E3.%20Restoring%20the%20ItemAdding%20event%2C%20we%20tried%20to%20set%20the%20remote%20event%20receiver's%20sequence%20to%2010000%2C%20but%20that%20doesnt%20change%20anything.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20it%20looks%20like%20copying%20to%20the%20same%20location%20causes%20SharePoint%20to%20overwrite%20new%20property%20values%20from%20the%20ItemAdding%20event%20receiver%20with%20the%20property%20values%20of%20the%20original%20document.%20While%20this%20is%20not%20the%20case%20when%20the%20document%20is%20copied%20to%20another%20location.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20need%20to%20be%20able%20to%20use%20the%20ItemAdding%20event.%20Does%20anyone%20have%20any%20clue%20what's%20going%20on%20here%3F%20Or%20how%20to%20solve%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAll%20help%20is%20very%20much%20appreciated!%20Thanks%20in%20advance.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3ERuud%20Hunnekens.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi!

 

Hope someone can help me with this problem we have... ;)

 

We have a custom addin, which generated a number for a document during the ItemAdding remote event receiver. When we add a document, it gets a number, let's say 001. When we use "Copy To" to copy the document to another location (another library or site), the copied document gets a new number, let's say 002. This is as expected.

However, when we copy the document this way to the current library, the new document gets the same number as the original document, which is 001. It should have been 003 now...

In the log file of our addin application, we can see that in every scenario, our addin software generates and assigns the newly generated number. However, the document has number 001 instead of 003.

What we've tried:

1. We have tried to copy the document to another folder within the same library. That has the same invalid result (same number as original).
2. We disabled the ItemAdding event receiver and enabled the ItemAdded event reveiver. In this case, the document that is copied to the same library as the original, gets a new number. So, this is good.

3. Restoring the ItemAdding event, we tried to set the remote event receiver's sequence to 10000, but that doesnt change anything.

 

So it looks like copying to the same location causes SharePoint to overwrite new property values from the ItemAdding event receiver with the property values of the original document. While this is not the case when the document is copied to another location.

 

We need to be able to use the ItemAdding event. Does anyone have any clue what's going on here? Or how to solve this?

 

All help is very much appreciated! Thanks in advance.

 

Cheers,

Ruud Hunnekens.

0 Replies