SharePoint “Feature”: Pain In The Ass…
Just to share some findings on working with SharePoint features:
- The Elements.xml file that you include with your feature deployment cannot contain XML comments; if it does, you will encounter an error when you try to activate your feature using STSADM.exe. Why? Who knows.
- The <type/> element in the Elements.xml file, according to the schema documentation, can only occur once. This seems to imply that you will need a different Elements.xml file to subscribe to each event type that you want to handle.
- And of course, Microsoft does not include the list of valid values (and if they do, it’s not easy to find in the documentation). Instead, I pulled the values using Reflector from the SPEventReceiverType enumeration.
The following is the enumeration listing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<FONT face="Courier new"><FONT color=#0000ff>public enum </FONT><FONT color=#000000>SPEventReceiverType </FONT><FONT color=#5e82fd>{</FONT> <FONT color=#000000>ContextEvent </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x7ffe</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>EmailReceived </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x4e20</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>FieldAdded </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2775</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>FieldAdding </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x65</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>FieldDeleted </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2777</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>FieldDeleting </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x67</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>FieldUpdated </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2776</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>FieldUpdating </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x66</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>InvalidReceiver </FONT><FONT color=#5e82fd>= -</FONT><FONT color=#000000>1</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#800080>ItemAdded </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2711</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemAdding </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>1</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemAttachmentAdded </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2717</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemAttachmentAdding </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>7</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemAttachmentDeleted </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2718</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemAttachmentDeleting </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>8</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemCheckedIn </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2714</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemCheckedOut </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2715</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemCheckingIn </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>4</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemCheckingOut </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>5</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#800080>ItemDeleted </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2713</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemDeleting </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>3</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemFileConverted </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x271a</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemFileMoved </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2719</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemFileMoving </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>9</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemUncheckedOut </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2716</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemUncheckingOut </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>6</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemUpdated </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x2712</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>ItemUpdating </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>2</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>SiteDeleted </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x27d9</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>SiteDeleting </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0xc9</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>WebDeleted </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x27da</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>WebDeleting </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0xca</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>WebMoved </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0x27db</FONT><FONT color=#5e82fd>,</FONT> <FONT color=#000000>WebMoving </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>0xcb</FONT> <FONT color=#5e82fd>}</FONT> </FONT> |
Of course, these values are in hexadecimal and for some reason, the <type/> element insists on the integer values. So just be sure to convert the value to integer (try using Google for that).